UTF16BE support in NStreamLineReader

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6344 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
anders_k 2013-04-11 15:28:45 +00:00
parent b0344c2712
commit eaa6991b91
3 changed files with 9 additions and 4 deletions

View file

@ -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})

View file

@ -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

View file

@ -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<LE|BE>")
#define TSTR_OUTPUTCHARSET _T("ACP|OEM|CP#|UTF8[SIG]|UTF16<LE|BE>[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); }