1 // Scintilla source code edit control
3 ** Functions to handle DBCS double byte encodings like Shift-JIS.
5 // Copyright 2017 by Neil Hodgson <neilh@scintilla.org>
6 // The License.txt file describes the conditions under which this software may be distributed.
10 using namespace Scintilla::Internal
;
12 namespace Scintilla::Internal
{
14 bool DBCSIsLeadByte(int codePage
, char ch
) noexcept
{
15 // Byte ranges found in Wikipedia articles with relevant search strings in each case
16 const unsigned char uch
= ch
;
20 return ((uch
>= 0x81) && (uch
<= 0x9F)) ||
21 ((uch
>= 0xE0) && (uch
<= 0xFC));
22 // Lead bytes F0 to FC may be a Microsoft addition.
25 return (uch
>= 0x81) && (uch
<= 0xFE);
27 // Korean Wansung KS C-5601-1987
28 return (uch
>= 0x81) && (uch
<= 0xFE);
31 return (uch
>= 0x81) && (uch
<= 0xFE);
33 // Korean Johab KS C-5601-1992
35 ((uch
>= 0x84) && (uch
<= 0xD3)) ||
36 ((uch
>= 0xD8) && (uch
<= 0xDE)) ||
37 ((uch
>= 0xE0) && (uch
<= 0xF9));
42 bool IsDBCSValidSingleByte(int codePage
, int ch
) noexcept
{
46 || (ch
>= 0xA0 && ch
<= 0xDF)