Chromium Code Reviews| Index: samples/pdfium_test.cc |
| diff --git a/samples/pdfium_test.cc b/samples/pdfium_test.cc |
| index 571bfcd3e697a18e77a8e59b275ca75a68dd7aba..9be59082c8ef24da83c747d1f10b067528924b7a 100644 |
| --- a/samples/pdfium_test.cc |
| +++ b/samples/pdfium_test.cc |
| @@ -197,16 +197,7 @@ void WriteEmf(FPDF_PAGE page, const char* pdf_name, int num) { |
| int ExampleAppAlert(IPDF_JSPLATFORM*, FPDF_WIDESTRING msg, FPDF_WIDESTRING, |
| int, int) { |
| // Deal with differences between UTF16LE and wchar_t on this platform. |
|
dsinclair
2015/11/04 14:15:07
Does this comment still apply?
Lei Zhang
2015/11/04 22:11:29
Moved.
|
| - size_t characters = 0; |
| - while (msg[characters]) { |
| - ++characters; |
| - } |
| - wchar_t* platform_string = |
| - static_cast<wchar_t*>(malloc((characters + 1) * sizeof(wchar_t))); |
| - for (size_t i = 0; i < characters + 1; ++i) { |
| - unsigned char* ptr = (unsigned char*)&msg[i]; |
| - platform_string[i] = ptr[0] + 256 * ptr[1]; |
| - } |
| + wchar_t* platform_string = GetWideString(msg); |
|
dsinclair
2015/11/04 14:15:07
unique_ptr?
Lei Zhang
2015/11/04 22:11:29
Went with std::wstring.
|
| printf("Alert: %ls\n", platform_string); |
| free(platform_string); |
| return 0; |