Index: Source/wtf/text/TextEncoding.cpp |
diff --git a/Source/wtf/text/TextEncoding.cpp b/Source/wtf/text/TextEncoding.cpp |
index 90a31d487f99ff88e57b3ff08605d7a6e8429242..eb5ded6bc3dcf4775b09f843621f215997c0cf52 100644 |
--- a/Source/wtf/text/TextEncoding.cpp |
+++ b/Source/wtf/text/TextEncoding.cpp |
@@ -72,6 +72,23 @@ CString TextEncoding::encode(const String& string, UnencodableHandling handling) |
if (string.isEmpty()) |
return ""; |
+ OwnPtr<TextCodec> textCodec = newTextCodec(*this); |
+ CString encodedString; |
+ if (string.is8Bit()) |
+ encodedString = textCodec->encode(string.characters8(), string.length(), handling); |
+ else |
+ encodedString = textCodec->encode(string.characters16(), string.length(), handling); |
+ return encodedString; |
+} |
+ |
+CString TextEncoding::normalizeAndEncode(const String& string, UnencodableHandling handling) const |
+{ |
+ if (!m_name) |
+ return CString(); |
+ |
+ if (string.isEmpty()) |
+ return ""; |
+ |
// Text exclusively containing Latin-1 characters (U+0000..U+00FF) is left |
// unaffected by NFC. This is effectively the same as saying that all |
// Latin-1 text is already normalized to NFC. |
@@ -79,10 +96,6 @@ CString TextEncoding::encode(const String& string, UnencodableHandling handling) |
if (string.is8Bit()) |
return newTextCodec(*this)->encode(string.characters8(), string.length(), handling); |
- // FIXME: What's the right place to do normalization? |
- // It's a little strange to do it inside the encode function. |
- // Perhaps normalization should be an explicit step done before calling encode. |
- |
const UChar* source = string.characters16(); |
size_t length = string.length(); |