wxStyledTextCtrl non ASCII characters

I realized that in wxStyledTextCtrl if the user's comments contains non-ASCII characters, the positions reported by WordStartPosition and WordEndPosition are wrong. What is a good way of dealing with non-ASCII characters in wxStyledTextCtrl? How can I identify the characters that are non-ASCII?


You've probably answered this question by now, but in the experiments I've done, WordStartPosition and WordEndPosition still work with non-ASCII characters. The data internally in the control is stored in UTF-8 format, and those functions give the number of bytes in that data where the word starts and ends. If that's not what's happening for you, can you post a sample where they don't work?

As for determining which characters are and aren't ASCII, something like the following seems to work (assuming a is the start and b is the end position):

wxString s = m_stc->GetTextRange(a,b);

for (wxString::const_iterator i = s.begin(); i != s.end(); ++i)
    wxUniChar uni_ch = *i;

        //something else

One thing I did notice is that if you use a value for a or b that falls in the middle of one of the non-ASCII characters, the resulting string will be empty. I hope this of some help if you haven't already found a solution.

Need Your Help

How to create a result set from a select query using multiple joins AND pull values from unlinked table where certain values exist

sql sql-server

I have a table which contains values for a collection of data. The value field thus contains multiple types of data - dates, numbers, text. One of the fields in the collection is a lookup to another

The Java BigDecimal vs The Financial Mans - "The 1 cent problem"

java bigdecimal

I have this problem: The financial mans says: "Error of your programation".