diff options
author | Tom Sepez <tsepez@chromium.org> | 2014-12-08 09:55:11 -0800 |
---|---|---|
committer | Tom Sepez <tsepez@chromium.org> | 2014-12-08 09:55:11 -0800 |
commit | fb9472868e3592d643d064135c7c91e4659962a8 (patch) | |
tree | d3aaa21b672b5faee4b1b79fc903937b48daec1c /samples | |
parent | 06428d249c139f9082ea8e01e6e91b5990756bd1 (diff) | |
download | pdfium-fb9472868e3592d643d064135c7c91e4659962a8.tar.xz |
Make app.alert() actually print its message under pdfium_test.
This is needed as an aid to testing.
R=thestig@chromium.org
Review URL: https://codereview.chromium.org/788433002
Diffstat (limited to 'samples')
-rw-r--r-- | samples/pdfium_test.cc | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/samples/pdfium_test.cc b/samples/pdfium_test.cc index d01602fc85..737846b36e 100644 --- a/samples/pdfium_test.cc +++ b/samples/pdfium_test.cc @@ -6,6 +6,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <wchar.h> #include <list> #include <string> @@ -135,8 +136,21 @@ void WriteEmf(FPDF_PAGE page, const char* pdf_name, int num) { } #endif -int Form_Alert(IPDF_JSPLATFORM*, FPDF_WIDESTRING, FPDF_WIDESTRING, int, int) { - printf("Form_Alert called.\n"); +int Form_Alert(IPDF_JSPLATFORM*, FPDF_WIDESTRING msg, FPDF_WIDESTRING, + int, int) { + // Deal with differences between UTF16LE and wchar_t on this platform. + size_t characters = 0; + while (msg[characters]) { + ++characters; + } + wchar_t* platform_string = + (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]; + } + printf("Alert: %ls\n", platform_string); + free(platform_string); return 0; } |