Index: testing/test_support.cpp |
diff --git a/testing/test_support.cpp b/testing/test_support.cpp |
index f71f6f8b4f6de6af2562c4269717b62ef0ded35d..c7ab10ee3cf2e8c3b15522e136728eca8b5042dc 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, |