#include "CharFormat.h"
#if defined VCZH_MSVC
#include <windows.h>
#elif defined VCZH_GCC
#include <string.h>
#endif
namespace
{
namespace
{
::
()
:stream(
0
)
,cacheSize(
0
)
{
}
void
::
(
*
)
{
=
;
}
void
::
()
{
}
::
(
void
*
,
)
{
const
=
+
;
const
=
all
/
sizeof
(
wchar_t
);
const
=
chars
*
sizeof
(
wchar_t
);
wchar_t
*
=
0
;
bool
=
false
;
=
0
;
if
(
chars
)
{
if
(
>
0
)
{
unicode
=
new
wchar_t
[
chars
];
(
unicode
,
,
);
(((
*)
unicode
)+
,
,
bytes
-
);
needToFree
=
true
;
}
else
{
unicode
=(
wchar_t
*)
;
}
result
=
(
unicode
,
chars
)*
sizeof
(
wchar_t
)-
;
=
0
;
}
if
(
needToFree
)
{
delete
[]
unicode
;
}
if
(
all
-
bytes
>
0
)
{
=
all
-
bytes
;
(
, (
*)
+
-
,
);
result
+=
;
}
return
result
;
}
::
()
:stream(
0
)
,cacheSize(
0
)
{
}
void
::
(
*
)
{
=
;
}
void
::
()
{
}
::
(
void
*
,
)
{
*
=(
*)
;
=
0
;
{
=
0
;
while
(
>
0
&&
>
0
)
{
*
unicode
++=
[
index
]++;
--;
--;
result
++;
}
}
const
=
/
sizeof
(
wchar_t
);
=
((
wchar_t
*)
unicode
,
chars
)*
sizeof
(
wchar_t
);
result
+=
bytes
;
-=
bytes
;
unicode
+=
bytes
;
if
(
>
0
)
{
wchar_t
;
if
(
(&
c
,
1
)==
1
)
{
=
sizeof
(
wchar_t
)-
;
(
unicode
, &
c
,
);
(
, (
*)&
c
+
,
);
result
+=
;
}
}
return
result
;
}
::
(
wchar_t
*
,
)
{
#if defined VCZH_MSVC
vint length=WideCharToMultiByte(CP_THREAD_ACP, 0, _buffer, (int)chars, NULL, NULL, NULL, NULL);
=
(
3
,
0
,
, (
int
)
,
0
,
0
,
0
,
0
);
char
*
=
new
char
[
length
];
WideCharToMultiByte(CP_THREAD_ACP, 0, _buffer, (int)chars, mbcs, (int)length, NULL, NULL);
(
3
,
0
,
, (
int
)
,
mbcs
, (
int
)
length
,
0
,
0
);
=
->
(
mbcs
,
length
);
delete
[]
mbcs
;
#elif defined VCZH_GCC
WString w(_buffer, chars);
AString a=wtoa(w);
vint length=a.Length();
vint result=stream->Write((void*)a.Buffer(), length);
#endif
if
(
result
==
length
)
{
return
;
}
else
{
();
return
0
;
}
}
::
(
wchar_t
*
,
)
{
char
*
=
new
char
[
*
2
];
char
*
=
source
;
=
0
;
while
(
readed
<
)
{
if
(
->
(
reading
,
1
)!=
1
)
{
break
;
}
#if defined VCZH_MSVC
if
(
(*
reading
))
#elif defined VCZH_GCC
if((vint8_t)*reading<0)
#endif
{
if
(
->
(
reading
+
1
,
1
)!=
1
)
{
break
;
}
reading
+=
2
;
}
else
{
reading
++;
}
readed
++;
}
#if defined VCZH_MSVC
MultiByteToWideChar(CP_THREAD_ACP, 0, source, (int)(reading-source), _buffer, (int)chars);
(
3
,
0
,
source
, (
int
)(
reading
-
source
),
, (
int
)
);
#elif defined VCZH_GCC
AString a(source, (vint)(reading-source));
WString w=atow(a);
memcpy(_buffer, w.Buffer(), readed*sizeof(wchar_t));
#endif
delete
[]
source
;
return
readed
;
}
::
(
wchar_t
*
,
)
{
#if defined VCZH_MSVC
return
->
(
,
*
sizeof
(
wchar_t
))/
sizeof
(
wchar_t
);
#elif defined VCZH_GCC
vint writed = 0;
vuint16_t utf16 = 0;
vuint8_t* utf16buf = (vuint8_t*)&utf16;
while (writed < chars)
{
wchar_t w = *_buffer++;
if (w < 0x10000)
{
utf16 = (vuint16_t)w;
if (stream->Write(&utf16buf[0], 1) != 1) break;
if (stream->Write(&utf16buf[1], 1) != 1) break;
}
else if (w < 0x110000)
{
wchar_t inc = w - 0x10000;
utf16 = (vuint16_t)(inc / 0x400) + 0xD800;
if (stream->Write(&utf16buf[0], 1) != 1) break;
if (stream->Write(&utf16buf[1], 1) != 1) break;
utf16 = (vuint16_t)(inc % 0x400) + 0xDC00;
if (stream->Write(&utf16buf[0], 1) != 1) break;
if (stream->Write(&utf16buf[1], 1) != 1) break;
}
else
{
break;
}
writed++;
}
if(writed!=chars)
{
Close();
}
return writed;
#endif
}
::
(
wchar_t
*
,
)
{
#if defined VCZH_MSVC
return
->
(
,
*
sizeof
(
wchar_t
))/
sizeof
(
wchar_t
);
#elif defined VCZH_GCC
wchar_t* writing = _buffer;
while (writing - _buffer < chars)
{
vuint16_t utf16_1 = 0;
vuint16_t utf16_2 = 0;
if (stream->Read(&utf16_1, 2) != 2) break;
if (utf16_1 < 0xD800 || utf16_1 > 0xDFFF)
{
*writing++ = (wchar_t)utf16_1;
}
else if (utf16_1 < 0xDC00)
{
if (stream->Read(&utf16_2, 2) != 2) break;
if (0xDC00 <= utf16_2 && utf16_2 <= 0xDFFF)
{
*writing++ = (wchar_t)(utf16_1 - 0xD800) * 0x400 + (wchar_t)(utf16_2 - 0xDC00) + 0x10000;
}
else
{
break;
}
}
else
{
break;
}
}
return writing - _buffer;
#endif
}
::
(
wchar_t
*
,
)
{
#if defined VCZH_MSVC
=
0
;
while
(
writed
<
)
{
if
(
->
(((
unsigned
char
*)
)+
1
,
1
)!=
1
)
{
break
;
}
if
(
->
(
,
1
)!=
1
)
{
break
;
}
++;
writed
++;
}
if
(
writed
!=
)
{
();
}
return
writed
;
#elif defined VCZH_GCC
vint writed = 0;
vuint16_t utf16 = 0;
vuint8_t* utf16buf = (vuint8_t*)&utf16;
while (writed < chars)
{
wchar_t w = *_buffer++;
if (w < 0x10000)
{
utf16 = (vuint16_t)w;
if (stream->Write(&utf16buf[1], 1) != 1) break;
if (stream->Write(&utf16buf[0], 1) != 1) break;
}
else if (w < 0x110000)
{
wchar_t inc = w - 0x10000;
utf16 = (vuint16_t)(inc / 0x400) + 0xD800;
if (stream->Write(&utf16buf[1], 1) != 1) break;
if (stream->Write(&utf16buf[0], 1) != 1) break;
utf16 = (vuint16_t)(inc % 0x400) + 0xDC00;
if (stream->Write(&utf16buf[1], 1) != 1) break;
if (stream->Write(&utf16buf[0], 1) != 1) break;
}
else
{
break;
}
writed++;
}
if(writed!=chars)
{
Close();
}
return writed;
#endif
}
::
(
wchar_t
*
,
)
{
#if defined VCZH_MSVC
=
->
(
,
*
sizeof
(
wchar_t
))/
sizeof
(
wchar_t
);
unsigned
char
*
=(
unsigned
char
*)
;
for
(
=
0
;
i
<
;
i
++)
{
unsigned
char
=
unicode
[
0
];
unicode
[
0
]=
unicode
[
1
];
unicode
[
1
]=
t
;
unicode
++;
}
return
;
#elif defined VCZH_GCC
wchar_t* writing = _buffer;
while (writing - _buffer < chars)
{
vuint16_t utf16_1 = 0;
vuint16_t utf16_2 = 0;
vuint8_t* utf16buf = 0;
vuint8_t utf16buf_temp = 0;
if (stream->Read(&utf16_1, 2) != 2) break;
utf16buf = (vuint8_t*)&utf16_1;
utf16buf_temp = utf16buf[0];
utf16buf[0] = utf16buf[1];
utf16buf[1] = utf16buf_temp;
if (utf16_1 < 0xD800 || utf16_1 > 0xDFFF)
{
*writing++ = (wchar_t)utf16_1;
}
else if (utf16_1 < 0xDC00)
{
if (stream->Read(&utf16_2, 2) != 2) break;
utf16buf = (vuint8_t*)&utf16_2;
utf16buf_temp = utf16buf[0];
utf16buf[0] = utf16buf[1];
utf16buf[1] = utf16buf_temp;
if (0xDC00 <= utf16_2 && utf16_2 <= 0xDFFF)
{
*writing++ = (wchar_t)(utf16_1 - 0xD800) * 0x400 + (wchar_t)(utf16_2 - 0xDC00) + 0x10000;
}
else
{
break;
}
}
else
{
break;
}
}
return writing - _buffer;
#endif
}
::
(
wchar_t
*
,
)
{
#if defined VCZH_MSVC
vint length=WideCharToMultiByte(CP_UTF8, 0, _buffer, (int)chars, NULL, NULL, NULL, NULL);
=
(
65001
,
0
,
, (
int
)
,
0
,
0
,
0
,
0
);
char
*
=
new
char
[
length
];
WideCharToMultiByte(CP_UTF8, 0, _buffer, (int)chars, mbcs, (int)length, NULL, NULL);
(
65001
,
0
,
, (
int
)
,
mbcs
, (
int
)
length
,
0
,
0
);
=
->
(
mbcs
,
length
);
delete
[]
mbcs
;
if
(
result
==
length
)
{
return
;
}
else
{
();
return
0
;
}
#elif defined VCZH_GCC
vint writed = 0;
while (writed < chars)
{
wchar_t w = *_buffer++;
vuint8_t utf8[4];
if (w < 0x80)
{
utf8[0] = (vuint8_t)w;
if (stream->Write(utf8, 1) != 1) break;
}
else if (w < 0x800)
{
utf8[0] = 0xC0 + ((w & 0x7C0) >> 6);
utf8[1] = 0x80 + (w & 0x3F);
if (stream->Write(utf8, 2) != 2) break;
}
else if (w < 0x10000)
{
utf8[0] = 0xE0 + ((w & 0xF000) >> 12);
utf8[1] = 0x80 + ((w & 0xFC0) >> 6);
utf8[2] = 0x80 + (w & 0x3F);
if (stream->Write(utf8, 3) != 3) break;
}
else if (w < 0x110000) // only accept UTF-16 range
{
utf8[0] = 0xF0 + ((w & 0x1C0000) >> 18);
utf8[1] = 0x80 + ((w & 0x3F000) >> 12);
utf8[2] = 0x80 + ((w & 0xFC0) >> 6);
utf8[3] = 0x80 + (w & 0x3F);
if (stream->Write(utf8, 4) != 4) break;
}
else
{
break;
}
writed++;
}
if(writed!=chars)
{
Close();
}
return writed;
#endif
}
::
()
#if defined VCZH_MSVC
:cache(
0
)
,cacheAvailable(
false
)
#endif
{
}
::
(
wchar_t
*
,
)
{
[
4
];
#if defined VCZH_MSVC
wchar_t
[
2
];
#endif
wchar_t
*
=
;
=
0
;
=
0
;
while
(
readed
<
)
{
#if defined VCZH_MSVC
if
(
)
{
*
writing
++=
;
=
0
;
=
false
;
}
else
{
#endif
if
(
->
(
source
,
1
)!=
1
)
{
break
;
}
if
((*
source
&
0xF0
) ==
0xF0
)
{
if
(
->
(
source
+
1
,
3
)!=
3
)
{
break
;
}
sourceCount
=
4
;
}
else
if
((*
source
&
0xE0
) ==
0xE0
)
{
if
(
->
(
source
+
1
,
2
)!=
2
)
{
break
;
}
sourceCount
=
3
;
}
else
if
((*
source
&
0xC0
) ==
0xC0
)
{
if
(
->
(
source
+
1
,
1
)!=
1
)
{
break
;
}
sourceCount
=
2
;
}
else
{
sourceCount
=
1
;
}
#if defined VCZH_MSVC
int targetCount=MultiByteToWideChar(CP_UTF8, 0, (char*)source, (int)sourceCount, target, 2);
int
=
(
65001
,
0
, (
char
*)
source
, (
int
)
sourceCount
,
target
,
2
);
if
(
targetCount
==
1
)
{
*
writing
++=
target
[
0
];
}
else
if
(
targetCount
==
2
)
{
*
writing
++=
target
[
0
];
=
target
[
1
];
=
true
;
}
else
{
break
;
}
}
#elif defined VCZH_GCC
if (sourceCount == 1)
{
*writing++ = (wchar_t)source[0];
}
else if (sourceCount == 2)
{
*writing++ = (((wchar_t)source[0] & 0x1F) << 6) + ((wchar_t)source[1] & 0x3F);
}
else if (sourceCount == 3)
{
*writing++ = (((wchar_t)source[0] & 0xF) << 12) + (((wchar_t)source[1] & 0x3F) << 6) + ((wchar_t)source[2] & 0x3F);
}
else if (sourceCount == 4)
{
*writing++ = (((wchar_t)source[0] & 0x7) << 18) + (((wchar_t)source[1] & 0x3F) << 12) + (((wchar_t)source[2] & 0x3F) << 6) + ((wchar_t)source[3] & 0x3F);
}
else
{
break;
}
#endif
readed
++;
}
return
readed
;
}
::
(
)
:encoding(
)
,encoder(
0
)
{
switch
(
)
{
case
:
=
new
;
break
;
case
:
=
new
;
break
;
case
:
=
new
;
break
;
case
:
=
new
;
break
;
}
}
::
()
{
();
}
void
::
(
*
)
{
switch
(
)
{
case
:
break
;
case
:
->
((
void
*)
"\xEF\xBB\xBF"
,
3
);
break
;
case
:
->
((
void
*)
"\xFF\xFE"
,
2
);
break
;
case
:
->
((
void
*)
"\xFE\xFF"
,
2
);
break
;
}
->
(
);
}
void
::
()
{
if
(
)
{
->
();
delete
;
=
0
;
}
}
::
(
void
*
,
)
{
return
->
(
,
);
}
::
::
(
*
,
char
*
,
)
:stream(
)
,bomPosition(
0
)
,bomLength(
)
{
(
,
,
);
}
bool
::
::
()
const
{
return
();
}
bool
::
::
()
const
{
return
false
;
}
bool
::
::
()
const
{
return
false
;
}
bool
::
::
()
const
{
return
false
;
}
bool
::
::
()
const
{
return
!=
0
&&
->
();
}
bool
::
::
()
const
{
return
!=
0
&&
->
();
}
void
::
::
()
{
=
0
;
}
::
::
()
const
{
return
()?
+
->
():-
1
;
}
::
::
()
const
{
return
-
1
;
}
void
::
::
(
)
{
CHECK_FAIL(L"BomDecoder::BomStream::Seek(pos_t)#Operation not supported.");
do
{
throw
(
L"BomDecoder::BomStream::Seek(pos_t)#Operation not supported."
);}
while
(
0
);
}
void
::
::
(
)
{
CHECK_FAIL(L"BomDecoder::BomStream::SeekFromBegin(pos_t)#Operation not supported.");
do
{
throw
(
L"BomDecoder::BomStream::SeekFromBegin(pos_t)#Operation not supported."
);}
while
(
0
);
}
void
::
::
(
)
{
CHECK_FAIL(L"BomDecoder::BomStream::SeekFromEnd(pos_t)#Operation not supported.");
do
{
throw
(
L"BomDecoder::BomStream::SeekFromEnd(pos_t)#Operation not supported."
);}
while
(
0
);
}
::
::
(
void
*
,
)
{
=
0
;
unsigned
char
*
=(
unsigned
char
*)
;
if
(
<
)
{
=
-
;
result
=
remain
<
?
remain
:
;
(
buffer
,
+
,
result
);
buffer
+=
result
;
+=
result
;
-=
result
;
}
if
(
)
{
result
+=
->
(
buffer
,
);
}
return
result
;
}
::
::
(
void
*
,
)
{
CHECK_FAIL(L"BomDecoder::BomStream::Write(void*, vint)#Operation not supported.");
do
{
throw
(
L"BomDecoder::BomStream::Write(void*, vint)#Operation not supported."
);}
while
(
0
);
}
::
::
(
void
*
,
)
{
CHECK_FAIL(L"BomDecoder::BomStream::Peek(void*, vint)#Operation not supported.");
do
{
throw
(
L"BomDecoder::BomStream::Peek(void*, vint)#Operation not supported."
);}
while
(
0
);
}
::
()
:decoder(
0
)
{
}
::
()
{
();
}
void
::
(
*
)
{
char
[
3
]={
0
};
=
->
(
bom
,
sizeof
(
bom
));
if
(
(
bom
,
"\xEF\xBB\xBF"
,
3
)==
0
)
{
=
new
;
=
new
(
,
bom
+
3
,
0
);
}
else
if
(
(
bom
,
"\xFF\xFE"
,
2
)==
0
)
{
=
new
;
=
new
(
,
bom
+
2
,
1
);
}
else
if
(
(
bom
,
"\xFE\xFF"
,
2
)==
0
)
{
=
new
;
=
new
(
,
bom
+
2
,
1
);
}
else
{
=
new
;
=
new
(
,
bom
,
3
);
}
->
(
);
}
void
::
()
{
if
(
)
{
->
();
delete
;
=
0
;
->
();
delete
;
=
0
;
}
}
::
(
void
*
,
)
{
return
->
(
,
);
}
bool
(
unsigned
char
*
,
)
{
for
(
=
0
;
i
<
;
i
++)
{
if
(
[
i
]==
0
)
return
false
;
}
return
true
;
}
bool
(
unsigned
char
*
,
)
{
for
(
=
0
;
i
<
;
i
++)
{
unsigned
char
=(
unsigned
char
)
[
i
];
if
(
c
==
0
)
{
return
false
;
}
else
{
=
0
;
if
((
c
&
0x80
)==
0x00
)
count10xxxxxx
=
0
;
else
if
((
c
&
0xE0
)==
0xC0
)
count10xxxxxx
=
1
;
else
if
((
c
&
0xF0
)==
0xE0
)
count10xxxxxx
=
2
;
else
if
((
c
&
0xF8
)==
0xF0
)
count10xxxxxx
=
3
;
else
if
((
c
&
0xFC
)==
0xF8
)
count10xxxxxx
=
4
;
else
if
((
c
&
0xFE
)==
0xFC
)
count10xxxxxx
=
5
;
if
(
<=
i
+
count10xxxxxx
)
{
return
false
;
}
else
{
for
(
=
0
;
j
<
count10xxxxxx
;
j
++)
{
c
=(
unsigned
char
)
[
i
+
j
+
1
];
if
((
c
&
0xC0
)!=
0x80
)
return
false
;
}
}
i
+=
count10xxxxxx
;
}
}
return
true
;
}
bool
(
unsigned
char
*
,
,
bool
&
)
{
=
false
;
if
(
%
2
!=
0
)
return
false
;
bool
=
false
;
for
(
=
0
;
i
<
;
i
+=
2
)
{
=
[
i
] + (
[
i
+
1
] <<
8
);
if
(
c
==
0
)
return
false
;
=
0
;
if
(
0xD800
<=
c
&&
c
<=
0xDBFF
)
type
=
1
;
else
if
(
0xDC00
<=
c
&&
c
<=
0xDFFF
)
type
=
2
;
if
(
needTrail
)
{
if
(
type
==
2
)
{
needTrail
=
false
;
}
else
{
return
false
;
}
}
else
{
if
(
type
==
1
)
{
needTrail
=
true
;
=
true
;
}
else
if
(
type
!=
0
)
{
return
false
;
}
}
}
return
!
needTrail
;
}
bool
(
unsigned
char
*
,
,
bool
&
)
{
=
false
;
if
(
%
2
!=
0
)
return
false
;
bool
=
false
;
for
(
=
0
;
i
<
;
i
+=
2
)
{
=
[
i
+
1
] + (
[
i
] <<
8
);
if
(
c
==
0
)
return
false
;
=
0
;
if
(
0xD800
<=
c
&&
c
<=
0xDBFF
)
type
=
1
;
else
if
(
0xDC00
<=
c
&&
c
<=
0xDFFF
)
type
=
2
;
if
(
needTrail
)
{
if
(
type
==
2
)
{
needTrail
=
false
;
}
else
{
return
false
;
}
}
else
{
if
(
type
==
1
)
{
needTrail
=
true
;
=
true
;
}
else
if
(
type
!=
0
)
{
return
false
;
}
}
}
return
!
needTrail
;
}
#if defined VCZH_MSVC
template
<
>
bool
(
int
(&
)[
],
bool
(&
)[
],
int
)
{
for
(
=
0
;
i
<
;
i
++)
{
if
(
[
i
] &
)
{
if
(
[
i
])
return
true
;
}
}
return
false
;
}
#endif
void
(
unsigned
char
*
,
,
::
&
,
bool
&
)
{
if
(
>=
3
&&
((
char
*)
,
"\xEF\xBB\xBF"
,
3
) ==
0
)
{
=
::
;
=
true
;
}
else
if
(
>=
2
&&
((
char
*)
,
"\xFF\xFE"
,
2
) ==
0
)
{
=
::
;
=
true
;
}
else
if
(
>=
2
&&
((
char
*)
,
"\xFE\xFF"
,
2
) ==
0
)
{
=
::
;
=
true
;
}
else
{
=
::
;
=
false
;
bool
=
false
;
bool
=
false
;
bool
=
(
,
);
bool
=
(
,
);
bool
=
(
,
,
utf16HitSurrogatePairs
);
bool
=
(
,
,
utf16BEHitSurrogatePairs
);
= (
roughMbcs
?
1
:
0
) + (
roughUtf8
?
1
:
0
) + (
roughUtf16
?
1
:
0
) + (
roughUtf16BE
?
1
:
0
);
if
(
roughCount
==
1
)
{
if
(
roughUtf8
)
=
::
;
else
if
(
roughUtf16
)
=
::
;
else
if
(
roughUtf16BE
)
=
::
;
}
else
if
(
roughCount
>
1
)
{
#if defined VCZH_MSVC
int
[] =
{
IS_TEXT_UNICODE_REVERSE_ASCII16,
IS_TEXT_UNICODE_REVERSE_STATISTICS,
IS_TEXT_UNICODE_REVERSE_CONTROLS,
IS_TEXT_UNICODE_STATISTICS,
IS_TEXT_UNICODE_CONTROLS,
IS_TEXT_UNICODE_ILLEGAL_CHARS,
IS_TEXT_UNICODE_ODD_LENGTH,
IS_TEXT_UNICODE_NULL_BYTES,
};
const
=
sizeof
(
tests
) /
sizeof
(*
tests
);
bool
[
TestCount
];
for
(
=
0
;
i
<
TestCount
;
i
++)
{
int
=
tests
[
i
];
results
[
i
] =
(
, (
int
)
, &
test
) !=
0
;
}
if
(
%
2
==
0
&& !GetEncodingResult(tests, results, IS_TEXT_UNICODE_REVERSE_ASCII16)
&& !
(
tests
,
results
,
0x0010
)
&& !GetEncodingResult(tests, results, IS_TEXT_UNICODE_REVERSE_STATISTICS)
&& !
(
tests
,
results
,
0x0020
)
&& !GetEncodingResult(tests, results, IS_TEXT_UNICODE_REVERSE_CONTROLS)
&& !
(
tests
,
results
,
0x0040
)
)
{
for
(
=
0
;
i
<
;
i
+=
2
)
{
unsigned
char
=
[
i
];
[
i
] =
[
i
+
1
];
[
i
+
1
] =
c
;
}
for
(
=
0
;
i
<
3
;
i
++)
{
int
=
tests
[
i
+
3
];
results
[
i
] =
(
, (
int
)
, &
test
) !=
0
;
}
for
(
=
0
;
i
<
;
i
+=
2
)
{
unsigned
char
=
[
i
];
[
i
] =
[
i
+
1
];
[
i
+
1
] =
c
;
}
}
if (GetEncodingResult(tests, results, IS_TEXT_UNICODE_NOT_UNICODE_MASK))
if
(
(
tests
,
results
,
0x0F00
))
{
if (GetEncodingResult(tests, results, IS_TEXT_UNICODE_NOT_ASCII_MASK))
if
(
(
tests
,
results
,
0xF000
))
{
=
::
;
}
else
if
(
roughUtf8
|| !
roughMbcs
)
{
=
::
;
}
}
else if (GetEncodingResult(tests, results, IS_TEXT_UNICODE_ASCII16))
else
if
(
(
tests
,
results
,
0x0001
))
{
=
::
;
}
else if (GetEncodingResult(tests, results, IS_TEXT_UNICODE_REVERSE_ASCII16))
else
if
(
(
tests
,
results
,
0x0010
))
{
=
::
;
}
else if (GetEncodingResult(tests, results, IS_TEXT_UNICODE_CONTROLS))
else
if
(
(
tests
,
results
,
0x0004
))
{
=
::
;
}
else if (GetEncodingResult(tests, results, IS_TEXT_UNICODE_REVERSE_CONTROLS))
else
if
(
(
tests
,
results
,
0x0040
))
{
=
::
;
}
else
{
if
(!
roughUtf8
)
{
if (GetEncodingResult(tests, results, IS_TEXT_UNICODE_STATISTICS))
if
(
(
tests
,
results
,
0x0002
))
{
=
::
;
}
else if (GetEncodingResult(tests, results, IS_TEXT_UNICODE_STATISTICS))
else
if
(
(
tests
,
results
,
0x0002
))
{
=
::
;
}
}
else if (GetEncodingResult(tests, results, IS_TEXT_UNICODE_NOT_UNICODE_MASK))
else
if
(
(
tests
,
results
,
0x0F00
))
{
=
::
;
}
else
if
(
roughUtf8
|| !
roughMbcs
)
{
=
::
;
}
}
#elif defined VCZH_GCC
if (roughUtf16 && roughUtf16BE && !roughUtf8)
{
if (utf16BEHitSurrogatePairs && !utf16HitSurrogatePairs)
{
encoding = BomEncoder::Utf16BE;
}
else
{
encoding = BomEncoder::Utf16;
}
}
else
{
encoding = BomEncoder::Utf8;
}
#endif
}
}
}
}
}