From c0360dd8fc15d0a86bc1057fb228882e2ee9f30a Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Fri, 5 Apr 2013 22:44:05 +1100 Subject: Replacing system calls for determining DBCS character width with own implementation to be same as other platforms and allow optimization. --- win32/PlatWin.cxx | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx index 6f11c4ea0..f23f0a6e8 100644 --- a/win32/PlatWin.cxx +++ b/win32/PlatWin.cxx @@ -1062,7 +1062,7 @@ void SurfaceGDI::MeasureWidths(Font &font_, const char *s, int len, XYPOSITION * int ui = 0; for (int i=0;i(ch); + switch (codePage) { + case 932: + // Shift_jis + return ((uch >= 0x81) && (uch <= 0x9F)) || + ((uch >= 0xE0) && (uch <= 0xEF)); + case 936: + // GBK + return (uch >= 0x81) && (uch <= 0xFE); + case 949: + // Korean Wansung KS C-5601-1987 + return (uch >= 0x81) && (uch <= 0xFE); + case 950: + // Big5 + return (uch >= 0x81) && (uch <= 0xFE); + case 1361: + // Korean Johab KS C-5601-1992 + return + ((uch >= 0x84) && (uch <= 0xD3)) || + ((uch >= 0xD8) && (uch <= 0xDE)) || + ((uch >= 0xE0) && (uch <= 0xF9)); + } + return false; } int Platform::DBCSCharLength(int codePage, const char *s) { - return (::IsDBCSLeadByteEx(codePage, s[0]) != 0) ? 2 : 1; + if (codePage == 932 || codePage == 936 || codePage == 949 || + codePage == 950 || codePage == 1361) { + return Platform::IsDBCSLeadByte(codePage, s[0]) ? 2 : 1; + } else { + return 1; + } } int Platform::DBCSCharMaxLength() { -- cgit v1.2.3