diff --git a/Docs/src/history.but b/Docs/src/history.but index 64b2faf0..d1f91822 100644 --- a/Docs/src/history.but +++ b/Docs/src/history.but @@ -6,7 +6,7 @@ Released on ?, 2013 \S1{v3.0a0-rl} Release Notes -\b MakeNSIS can now generate ANSI and \R{intro-unicode}{Unicode} installers. Source files can be UTF8SIG, UTF16LE or traditional MBCS text files (which are converted to Unicode with ACP unless you specify a different codepage). The default plugins are now stored in sub-folders based on their CPU target and character set encoding. +\b MakeNSIS can now generate ANSI and \R{intro-unicode}{Unicode} installers. Source files can be UTF8SIG, UTF16BOM or traditional MBCS text files (which are converted to Unicode with ACP unless you specify a different codepage). The default plugins are now stored in sub-folders based on their CPU target and character set encoding. \S1{v3.0a0-cl} Changelog @@ -14,7 +14,7 @@ Released on ?, 2013 \b Added the \R{aunicodetarget}{Unicode} attribute (\W{http://sourceforge.net/support/tracker.php?aid=1238132}{RFE #1238132}, \W{http://sourceforge.net/support/tracker.php?aid=1795257}{patch #1795257}) -\b MakeNSIS can read UTF8SIG and UTF16LE script files (\W{http://sourceforge.net/support/tracker.php?aid=2026892}{RFE #2026892}) +\b MakeNSIS can read UTF8SIG and UTF16BOM script files (\W{http://sourceforge.net/support/tracker.php?aid=2026892}{RFE #2026892}) \b All NLF and NSH language files are stored in Unicode (\W{http://sourceforge.net/support/tracker.php?aid=1879642}{RFE #1879642}) diff --git a/Source/utf.cpp b/Source/utf.cpp index bf8967ca..ea373081 100644 --- a/Source/utf.cpp +++ b/Source/utf.cpp @@ -484,16 +484,18 @@ l_restart: if (CompleteLine(Buffer,cchWC,cchBuf,true)) goto l_success; } } - else if (StreamEncoding().IsUTF16LE()) + else if (StreamEncoding().IsUTF16()) { #ifndef _WIN32 if (!iconvd.Open("wchar_t", iconvd::GetHostEndianUCS4Code())) goto ERR_UNSUPPORTEDENCODING; #endif + const bool utf16be = StreamEncoding().IsUTF16BE(); unsigned short lead, trail, cchWC; for(;;) { if (!strm.ReadInt16(&lead)) goto l_ioerror; FIX_ENDIAN_INT16LETOHOST_INPLACE(lead); + if (utf16be) lead = SWAP_ENDIAN_INT16(lead); if (IsTrailSurrogateUTF16(lead)) goto l_badutf; UINT32 codpt = lead; if (cchBuf <= 1) goto l_lineoverflow; @@ -502,6 +504,7 @@ l_restart: { if (!strm.ReadInt16(&trail)) goto l_ioerror; FIX_ENDIAN_INT16LETOHOST_INPLACE(trail); + if (utf16be) trail = SWAP_ENDIAN_INT16(trail); if (!IsTrailSurrogateUTF16(trail)) goto l_badutf; codpt = CodePointFromUTF16SurrogatePair(lead,trail); #ifdef _WIN32 diff --git a/Source/utf.h b/Source/utf.h index a2cad855..5512a5b5 100644 --- a/Source/utf.h +++ b/Source/utf.h @@ -29,7 +29,7 @@ const WORD UNICODE_REPLACEMENT_CHARACTER = 0xfffd; -#define TSTR_INPUTCHARSET _T("ACP|OEM|CP#|UTF8|UTF16LE") +#define TSTR_INPUTCHARSET _T("ACP|OEM|CP#|UTF8|UTF16") #define TSTR_OUTPUTCHARSET _T("ACP|OEM|CP#|UTF8[SIG]|UTF16[BOM]") @@ -163,7 +163,9 @@ public: #endif } bool IsUTF8() const { return UTF8==GetCodepage(); } + bool IsUTF16() const { return (UTF16LE|1)==(GetCodepage()|1); } bool IsUTF16LE() const { return UTF16LE==GetCodepage(); } + bool IsUTF16BE() const { return UTF16BE==GetCodepage(); } bool IsUnicode() const { return IsUnicodeCodepage(GetCodepage()); } void GetCPDisplayName(TCHAR*Buf) { GetCPDisplayName(m_cp, Buf); }