diff options
| author | mitchell <unknown> | 2018-05-05 11:52:27 -0400 |
|---|---|---|
| committer | mitchell <unknown> | 2018-05-05 11:52:27 -0400 |
| commit | 93462d87c3c8f398d5900be84349f29cb088d849 (patch) | |
| tree | 631eb19ad8d818e262f4988139d96709b4ee8cd5 /win32 | |
| parent | 156c3f0e53ea2a7f932f6079cb122c2cf66fb3df (diff) | |
| download | scintilla-mirror-93462d87c3c8f398d5900be84349f29cb088d849.tar.gz | |
Backport: Feature [feature-requests:#1211]. Use pre-computed table for UTF8BytesOfLead.
Friendlier treatment of invalid UTF-8. Add tests for UniConversion handling invalid UTF-8. Simplify UTF8Classify tests.
Backport of changeset 6643:ebbb4e5aaf93.
Diffstat (limited to 'win32')
| -rw-r--r-- | win32/PlatWin.cxx | 19 | ||||
| -rw-r--r-- | win32/scintilla.mak | 2 |
2 files changed, 9 insertions, 12 deletions
diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx index 9e89e2f84..79970a969 100644 --- a/win32/PlatWin.cxx +++ b/win32/PlatWin.cxx @@ -951,12 +951,14 @@ void SurfaceGDI::MeasureWidths(Font &font_, const char *s, int len, XYPOSITION * return; } // Map the widths given for UTF-16 characters back onto the UTF-8 input string + const unsigned char *us = reinterpret_cast<const unsigned char *>(s); for (int ui = 0; ui < fit; ui++) { - const unsigned int lenChar = UTF8BytesOfLead[static_cast<unsigned char>(s[i])]; - if (lenChar == 4) { // Non-BMP + const unsigned char uch = us[i]; + const unsigned int byteCount = UTF8BytesOfLead[uch]; + if (byteCount == 4) { // Non-BMP ui++; } - for (unsigned int bytePos=0; (bytePos<lenChar) && (i<len); bytePos++) { + for (unsigned int bytePos=0; (bytePos<byteCount) && (i<len); bytePos++) { positions[i++] = static_cast<XYPOSITION>(poses.buffer[ui]); } } @@ -1623,16 +1625,11 @@ void SurfaceD2D::MeasureWidths(Font &font_, const char *s, int len, XYPOSITION * int i=0; while (ui<tbuf.tlen) { const unsigned char uch = us[i]; - unsigned int lenChar = 1; - if (uch >= (0x80 + 0x40 + 0x20 + 0x10)) { - lenChar = 4; + const unsigned int byteCount = UTF8BytesOfLead[uch]; + if (byteCount == 4) { // Non-BMP ui++; - } else if (uch >= (0x80 + 0x40 + 0x20)) { - lenChar = 3; - } else if (uch >= (0x80)) { - lenChar = 2; } - for (unsigned int bytePos=0; (bytePos<lenChar) && (i<len); bytePos++) { + for (unsigned int bytePos=0; (bytePos<byteCount) && (i<len); bytePos++) { positions[i++] = poses.buffer[ui]; } ui++; diff --git a/win32/scintilla.mak b/win32/scintilla.mak index 5c9360dff..15c2c1279 100644 --- a/win32/scintilla.mak +++ b/win32/scintilla.mak @@ -62,7 +62,7 @@ CXXFLAGS=$(CXXFLAGS) $(INCLUDEDIRS) all: $(COMPONENT) $(LEXCOMPONENT) $(LIBSCI) clean: - -del /q $(DIR_O)\*.obj $(DIR_O)\*.pdb $(COMPONENT) $(LEXCOMPONENT) \ + -del /q $(DIR_O)\*.obj $(DIR_O)\*.pdb $(DIR_O)\*.asm $(COMPONENT) $(LEXCOMPONENT) \ $(DIR_O)\*.res $(DIR_BIN)\*.map $(DIR_BIN)\*.exp $(DIR_BIN)\*.pdb $(DIR_BIN)\*.lib # Required for base Scintilla |
