summaryrefslogtreecommitdiff
path: root/testing/test_support.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2016-01-05 10:06:09 -0800
committerTom Sepez <tsepez@chromium.org>2016-01-05 10:06:09 -0800
commited34cdf99d5a4b33e57f81f9244a311f6fb86db3 (patch)
treeee5c9711c68cb3971ce058400a6f777324873e60 /testing/test_support.cpp
parent5dac8047f02c937a5a3546a8cc5b352db2188d97 (diff)
downloadpdfium-ed34cdf99d5a4b33e57f81f9244a311f6fb86db3.tar.xz
Make FPDF_WIDESTRING work regardless of endianness.
Given the helper routines, use it in the find bookmark test instead of just trusting another bookmarks title. R=thestig@chromium.org Review URL: https://codereview.chromium.org/1554363002 .
Diffstat (limited to 'testing/test_support.cpp')
-rw-r--r--testing/test_support.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/testing/test_support.cpp b/testing/test_support.cpp
index f71f6f8b4f..c7ab10ee3c 100644
--- a/testing/test_support.cpp
+++ b/testing/test_support.cpp
@@ -98,7 +98,7 @@ char* GetFileContents(const char* filename, size_t* retlen) {
return buffer;
}
-std::wstring GetWideString(FPDF_WIDESTRING wstr) {
+std::wstring GetPlatformWString(FPDF_WIDESTRING wstr) {
if (!wstr)
return nullptr;
@@ -114,6 +114,19 @@ std::wstring GetWideString(FPDF_WIDESTRING wstr) {
return platform_string;
}
+FPDF_WIDESTRING GetFPDFWideString(const std::wstring& wstr) {
+ size_t length = sizeof(uint16_t) * (wstr.length() + 1);
+ unsigned char* ptr = static_cast<unsigned char*>(malloc(length));
+ size_t i = 0;
+ for (wchar_t w : wstr) {
+ ptr[i++] = w & 0xff;
+ ptr[i++] = (w >> 8) & 0xff;
+ }
+ ptr[i++] = 0;
+ ptr[i] = 0;
+ return reinterpret_cast<FPDF_WIDESTRING>(ptr);
+}
+
#ifdef PDF_ENABLE_V8
#ifdef V8_USE_EXTERNAL_STARTUP_DATA
bool InitializeV8ForPDFium(const std::string& exe_path,