- work as before. If you need to have a wxString that uses wchar_t on Unix
- and Linux, too, you can specify this on the command line with the
- @c configure @c --disable-utf8 switch.
-
- If you need a Unicode string class with O(1) access on all platforms
- you should consider using wxUString.
-
- Since iterating over a wxString by index can become inefficient in UTF-8
- mode iterators should be used instead of index based access:
+ work as before. If you nonetheless need to have a wxString that uses wchar_t
+ on Unix and Linux, too, you can specify this on the command line with the
+ @c configure @c --disable-utf8 switch or you can consider using wxUString
+ or std::wstring instead.
+
+ Accessing a UTF-8 string by index can be very inefficient because
+ a single character is represented by a variable number of bytes so that
+ the entire string has to be parsed in order to find the character.
+ Since iterating over a string by index is a common programming technique and
+ was also possible and encouraged by wxString using the access operator[]()
+ wxString implements caching of the last used index so that iterating over
+ a string is a linear operation even in UTF-8 mode.
+
+ It is nonetheless recommended to use iterators (instead of index based
+ access) like this: