StyledTextCtrl.GetStyledText() returns random data?

This issue should be reported to wxWidgets. But I think GetStyledText is rarely needed. :slightly_smiling_face:

From your previous post, I guess you are trying to get the style number of the text.
FYI
The style number that GetStyledText returns is the number that the Lexer automatically assigns to the token. For example, if SetLexer(stc.STC_LEX_PYTHON) is used, one of the following 16 styles are assigned to each token:

wx.stc.STC_P_DEFAULT                        0
wx.stc.STC_P_COMMENTLINE                    1
wx.stc.STC_P_NUMBER                         2
wx.stc.STC_P_STRING                         3
wx.stc.STC_P_CHARACTER                      4
wx.stc.STC_P_WORD                           5
wx.stc.STC_P_TRIPLE                         6
wx.stc.STC_P_TRIPLEDOUBLE                   7
wx.stc.STC_P_CLASSNAME                      8
wx.stc.STC_P_DEFNAME                        9
wx.stc.STC_P_OPERATOR                       10
wx.stc.STC_P_IDENTIFIER                     11
wx.stc.STC_P_COMMENTBLOCK                   12
wx.stc.STC_P_STRINGEOL                      13
wx.stc.STC_P_WORD2                          14
wx.stc.STC_P_DECORATOR                      15

If you want to get the indicator number such as stc.STC_INDIC_SQUIGGLE, the following methods should be used:

IndicatorValueAt(indicator, pos) -> int
IndicatorStart(indicator, pos) -> int
IndicatorEnd(indicator, pos) -> int
IndicatorAllOnFor(pos) -> int