diff options
Diffstat (limited to 'src/DBCS.h')
-rw-r--r-- | src/DBCS.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/DBCS.h b/src/DBCS.h index 01830c843..12bbaf986 100644 --- a/src/DBCS.h +++ b/src/DBCS.h @@ -25,8 +25,29 @@ constexpr bool IsDBCSCodePage(int codePage) noexcept { } bool DBCSIsLeadByte(int codePage, char ch) noexcept; +bool DBCSIsTrailByte(int codePage, char ch) noexcept; bool IsDBCSValidSingleByte(int codePage, int ch) noexcept; +// Calculate a number from a DBCS byte pair that can be used to index into an array or map. +// Should only be called with genuine DBCS character pairs which means that ch1 has top bit set. +constexpr uint16_t DBCSIndex(char ch1, char ch2) noexcept { + constexpr unsigned int highStart = 0x80U; + constexpr unsigned int byteMultiply = 0x100U; + const unsigned char uch1 = ch1; + const unsigned char uch2 = ch2; + return ((uch1 - highStart) * byteMultiply) + uch2; +} + +struct DBCSPair { + char chars[2]; +}; +using FoldMap = std::array<DBCSPair, 0x8000>; + +bool DBCSHasFoldMap(int codePage); +void DBCSSetFoldMap(int codePage, const FoldMap &foldMap); +FoldMap *DBCSGetMutableFoldMap(int codePage); +const FoldMap *DBCSGetFoldMap(int codePage); + } #endif |