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:
parent
b0344c2712
commit
eaa6991b91
3 changed files with 9 additions and 4 deletions
|
@ -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
|
||||
|
|
|
@ -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); }
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue