Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(297)

Unified Diff: samples/pdfium_test.cc

Issue 788433002: Make app.alert() actually print its message under pdfium_test. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: fix whitespace Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: samples/pdfium_test.cc
diff --git a/samples/pdfium_test.cc b/samples/pdfium_test.cc
index d01602fc8547398b6f54ab842a816a3351d79b19..737846b36e472a9da5a45e24ba93081693a66f84 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;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698