Which text control should I use to load large files?

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
purplex88
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 247
Joined: Mon Feb 24, 2014 3:14 pm

Re: Which text control should I use to load large files?

Post by purplex88 »

Yes, I need std::string to able to use it with std::stringstream and std::getline in order to do some parsing.

I am reading from docs that I can use:

Code: Select all

wxUSE_UNICODE_UTF8=1
if I want UTF-8 wxString in transparent way everywhere. Do I use this in preprocessor under Visual Studio 2015 -> Properties -> C/C++ -> Preprocessor Definitions ? I tried but it didn't work as expected.
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4204
Joined: Sun Jan 03, 2010 5:45 pm

Re: Which text control should I use to load large files?

Post by PB »

Firstly, you would need to build wxWidgets for defalt UTF-8 encoding.

Secondly, I do not think it is recommended or even supported on MSW.

See this section for more information, preferrably read the whole page there.
purplex88
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 247
Joined: Mon Feb 24, 2014 3:14 pm

Re: Which text control should I use to load large files?

Post by purplex88 »

I see. After some looking up I found that I can use std::wstring. This should work without any encoding problems.

Things are becoming clear now. So, that means the wxWidget controls e.g. wxTextCtrl and wxListCtrl in particular are using UTF-16 to handle and display data?
User avatar
doublemax
Moderator
Moderator
Posts: 19160
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Which text control should I use to load large files?

Post by doublemax »

So, that means the wxWidget controls e.g. wxTextCtrl and wxListCtrl in particular are using UTF-16 to handle and display data?
Not exactly.

wxString under Windows uses UTF-16 to store string data internally. As do the native controls under Windows (in Unicode).

But in most cases you don't have to care about this and consider wxString a black box. Only when you need a specific encoding, you can use ToUTF8 or the more generic mb_str(...) to get it.
Use the source, Luke!
purplex88
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 247
Joined: Mon Feb 24, 2014 3:14 pm

Re: Which text control should I use to load large files?

Post by purplex88 »

Makes sense. If I want wxTextCtrl and wxListCtrl to interpret data as UTF-8 for display, do I need to re-compile wxWidgets?
User avatar
doublemax
Moderator
Moderator
Posts: 19160
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Which text control should I use to load large files?

Post by doublemax »

If I want wxTextCtrl and wxListCtrl to interpret data as UTF-8 for display, do I need to re-compile wxWidgets?
Theoretically you can make wxWidgets use UTF8 as internal storage for strings. But as PB already mentioned, i don't think this is fully supported under Windows. It will probably cause more problems than it solves. My recommendation: Don't do it.
Use the source, Luke!
Post Reply