johnsonj:
> it works well for ime input.
> but caret can move inside a character since it moves byte to byte.
OK, that appears to stop that idea. I’m most interested in avoiding crashes like the one reported by a Chinese user below.
Looks ike treating SC_CHARSET_DEFAULT as the European single byte code page 1252 when there is no explicit code page is safer. That is, in CodePageFromCharSet, something like:
switch (characterSet) {
case SC_CHARSET_ANSI: return 1252;
case SC_CHARSET_DEFAULT: return documentCodePage ? documentCodePage : 1252;
Stack trace of crash:
> SciTE.exe!Platform::Assert(const char * c, const char * file, int line) 行 3152 C++
SciTE.exe!SurfaceD2D::MeasureWidths(Font & font_, const char * s, int len, float * positions) 行 1662 C++
SciTE.exe!PositionCache::MeasureWidths(Surface * surface, const ViewStyle & vstyle, unsigned int styleNumber, const char * s, unsigned int len, float * positions, Document * pdoc) 行 689 C++
SciTE.exe!EditView::LayoutLine(const EditModel & model, int line, Surface * surface, const ViewStyle & vstyle, LineLayout * ll, int width) 行 498 C++
SciTE.exe!EditView::PaintText(Surface * surfaceWindow, const EditModel & model, PRectangle rcArea, PRectangle rcClient, const ViewStyle & vsDraw) 行 1850 C++
SciTE.exe!Editor::Paint(Surface * surfaceWindow, PRectangle rcArea) 行 1756 C++
SciTE.exe!ScintillaWin::WndPaint(unsigned long wParam) 行 819 C++
SciTE.exe!ScintillaWin::WndProc(unsigned int iMessage, unsigned long wParam, long lParam) 行 1241 C++
SciTE.exe!ScintillaWin::SWndProc(HWND__ * hWnd, unsigned int iMessage, unsigned int wParam, long lParam) 行 3409 C++
[外部代码]
SciTE.exe!WinMain(HINSTANCE__ * hInstance, HINSTANCE__ * __formal, char * __formal, int __formal) 行
Even with assertions off, this leads to bad position information which leads to buggy behaviour.
Neil