summaryrefslogtreecommitdiff
path: root/testing
diff options
context:
space:
mode:
Diffstat (limited to 'testing')
-rw-r--r--testing/test_support.cpp8
-rw-r--r--testing/test_support.h4
2 files changed, 12 insertions, 0 deletions
diff --git a/testing/test_support.cpp b/testing/test_support.cpp
index 1ad8543bae..e5c3ab45a0 100644
--- a/testing/test_support.cpp
+++ b/testing/test_support.cpp
@@ -9,6 +9,7 @@
#include "core/fdrm/crypto/fx_crypt.h"
#include "core/fxcrt/fx_memory.h"
+#include "core/fxcrt/fx_string.h"
#include "testing/utils/path_service.h"
#ifdef PDF_ENABLE_V8
@@ -103,6 +104,13 @@ std::unique_ptr<char, pdfium::FreeDeleter> GetFileContents(const char* filename,
return buffer;
}
+std::string GetPlatformString(FPDF_WIDESTRING wstr) {
+ return std::string(
+ CFX_WideString::FromUTF16LE(wstr, CFX_WideString::WStringLength(wstr))
+ .UTF8Encode()
+ .c_str());
+}
+
std::wstring GetPlatformWString(FPDF_WIDESTRING wstr) {
if (!wstr)
return nullptr;
diff --git a/testing/test_support.h b/testing/test_support.h
index 7676e5783b..feec4bbe0b 100644
--- a/testing/test_support.h
+++ b/testing/test_support.h
@@ -62,6 +62,10 @@ std::unique_ptr<char, pdfium::FreeDeleter> GetFileContents(const char* filename,
std::vector<std::string> StringSplit(const std::string& str, char delimiter);
+// Converts a FPDF_WIDESTRING to a std::string.
+// Deals with differences between UTF16LE and UTF8.
+std::string GetPlatformString(FPDF_WIDESTRING wstr);
+
// Converts a FPDF_WIDESTRING to a std::wstring.
// Deals with differences between UTF16LE and wchar_t.
std::wstring GetPlatformWString(FPDF_WIDESTRING wstr);