From 3140d902dabbd0bb5921b4eaba030b9c29d438a5 Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Wed, 25 Jan 2012 00:21:27 +0000 Subject: [PATCH] Report the endianness of detected UTF-16 and UTF-32 'UTF-16' is big-endian UTF-16, so returning it for UTF-16LE is incorrect and results in line_iterator failing on UTF-16LE. Originally committed to SVN as r6351. --- aegisub/universalchardet/nsUniversalDetector.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/aegisub/universalchardet/nsUniversalDetector.cpp b/aegisub/universalchardet/nsUniversalDetector.cpp index 1f495228b..cd6053e09 100644 --- a/aegisub/universalchardet/nsUniversalDetector.cpp +++ b/aegisub/universalchardet/nsUniversalDetector.cpp @@ -125,12 +125,12 @@ nsresult nsUniversalDetector::HandleData(const char* aBuf, PRUint32 aLen) mDetectedCharset = "X-ISO-10646-UCS-4-3412"; else if ('\xFF' == aBuf[1]) // FE FF UTF-16, big endian BOM - mDetectedCharset = "UTF-16"; + mDetectedCharset = "UTF-16BE"; break; case '\x00': if (('\x00' == aBuf[1]) && ('\xFE' == aBuf[2]) && ('\xFF' == aBuf[3])) // 00 00 FE FF UTF-32, big-endian BOM - mDetectedCharset = "UTF-32"; + mDetectedCharset = "UTF-32BE"; else if (('\x00' == aBuf[1]) && ('\xFF' == aBuf[2]) && ('\xFE' == aBuf[3])) // 00 00 FF FE UCS-4, unusual octet order BOM (2143) mDetectedCharset = "X-ISO-10646-UCS-4-2143"; @@ -138,10 +138,10 @@ nsresult nsUniversalDetector::HandleData(const char* aBuf, PRUint32 aLen) case '\xFF': if (('\xFE' == aBuf[1]) && ('\x00' == aBuf[2]) && ('\x00' == aBuf[3])) // FF FE 00 00 UTF-32, little-endian BOM - mDetectedCharset = "UTF-32"; + mDetectedCharset = "UTF-32LE"; else if ('\xFE' == aBuf[1]) // FF FE UTF-16, little endian BOM - mDetectedCharset = "UTF-16"; + mDetectedCharset = "UTF-16LE"; break; } // switch