Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scintilla Supports Unicode? What about SCI_GETCHARAT?

Does Scintilla really support Unicode? If so, why does SCI_GETCHARAT return a char value (casted to LRESULT)?

like image 875
user541686 Avatar asked May 29 '11 17:05

user541686


2 Answers

From the SCI_SETCODEPAGE docs...

Code page SC_CP_UTF8 (65001) sets Scintilla into Unicode mode with the document treated as a sequence of characters expressed in UTF-8. The text is converted to the platform's normal Unicode encoding before being drawn by the OS and thus can display Hebrew, Arabic, Cyrillic, and Han characters.

You will have to examine the byte you retrieve with SCI_GETCHARAT(pos) and, depending on the top bits of that, maybe read SCI_GETCHARAT(pos+1) and beyond in order to get the Unicode code point. (See here.)

Edit:

For some C++ code that does this, see below (search for SciMoz::GetWCharAt):

http://vacuproj.googlecode.com/svn/trunk/npscimoz/npscimoz/oldsrc/trunk.nsSciMoz.cxx

like image 192
Martin Stone Avatar answered Dec 20 '22 06:12

Martin Stone


I was long time ago but if I remember well Scintilla is not a native Unicode application. Still it has some Unicode support.

First, the function name should SCI_GETBYTEAT, because it returns a byte from UTF-8 internal buffer.

Also, the application has Unicode support for keybaord, so it has some Unicode support :)

like image 42
sorin Avatar answered Dec 20 '22 07:12

sorin