From 4442d453f570fda76ec4852e2bb03e7ec8bfb825 Mon Sep 17 00:00:00 2001 From: Jane Liu Date: Wed, 19 Jul 2017 10:19:42 -0400 Subject: Added testing flag --save-attachments that saves embedded attachments 1. Added --save-attachments flag in pdfium_test to save embedded attachments using fpdf_attachment APIs. Bug=pdfium:174 Change-Id: I62f09aeb0ab1431f6e127da389518878a7214423 Reviewed-on: https://pdfium-review.googlesource.com/7990 Commit-Queue: Jane Liu Reviewed-by: dsinclair --- testing/test_support.cpp | 8 ++++++++ testing/test_support.h | 4 ++++ 2 files changed, 12 insertions(+) (limited to 'testing') 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 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 GetFileContents(const char* filename, std::vector 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); -- cgit v1.2.3