From 34dab07ed6e826666fd0589069f2c9b5bd2ba4dc Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Wed, 8 Aug 2018 17:49:02 +0000 Subject: Move ByteString::FromUnicode() to WideString::ToDefANSI() Turns out that "FromUnicode" is misleading in that, on linux, it simply removes any characters beyond 0xFF and passes the rest unchanged, so no unicode decoding actually takes place. On Windows, it passes it into the system function specifying FX_CODEPAGE_DefANSI, converting it into the so-called "default ANSI code plane", passing some characters, converting others to '?' and still others to 'A'. Either way, nothing resembling UTF8 comes out of this, so pick a better name. These now immediately look suspicious, so a follow-up CL will see which ones should really be WideString::UTF8Encode() instead. Making this a normal method on a widestring rather than a static method on a bytestring feels more natural; this is parallel to the UTF8Encode and UTF16LE_Encode functions. Add a test that shows these conversions. Change-Id: Ia7551b47199eba61b5c328a97bfe9176ac8e583c Reviewed-on: https://pdfium-review.googlesource.com/39690 Reviewed-by: Lei Zhang Commit-Queue: Tom Sepez --- core/fxge/win32/fx_win32_print.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'core/fxge/win32') diff --git a/core/fxge/win32/fx_win32_print.cpp b/core/fxge/win32/fx_win32_print.cpp index f36fa84364..1e2b2d4e9a 100644 --- a/core/fxge/win32/fx_win32_print.cpp +++ b/core/fxge/win32/fx_win32_print.cpp @@ -650,7 +650,7 @@ bool CTextOnlyPrinterDriver::DrawDeviceText(int nChars, wsText += charpos.m_Unicode; } size_t len = totalLength; - ByteString text = ByteString::FromUnicode(wsText); + ByteString text = wsText.ToDefANSI(); while (len > 0) { char buffer[1026]; size_t send_len = std::min(len, static_cast(1024)); -- cgit v1.2.3