SkPDF: Fix encoding of unichr outside of basic plane
In ToUnicode table, write unicode codepoints as one or two UTF16BE
values, rather than a single hex, as the standard requires.
Factor out uint16 -> big-endian hex code.
SkUtils is now a namespace.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2120533002
Review-Url: https://codereview.chromium.org/2120533002
diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp
index 12698dc..7c366cd 100644
--- a/src/pdf/SkPDFDevice.cpp
+++ b/src/pdf/SkPDFDevice.cpp
@@ -1063,15 +1063,9 @@
bool wideChars) {
if (wideChars) {
SkASSERT(2 * len < 65535);
- static const char gHex[] = "0123456789ABCDEF";
wStream->writeText("<");
for (size_t i = 0; i < len; i++) {
- char result[4]; // Big-endian
- result[0] = gHex[(input[i] >> 12) & 0xF];
- result[1] = gHex[(input[i] >> 8) & 0xF];
- result[2] = gHex[(input[i] >> 4) & 0xF];
- result[3] = gHex[(input[i]) & 0xF];
- wStream->write(result, 4);
+ SkPDFUtils::WriteUInt16BE(wStream, input[i]);
}
wStream->writeText(">");
} else {