Ticket #15611 (closed defect: fixed)
Inconsisten font encoding used in wxTextCtrl::LoadFile/SaveFile() functions
|Reported by:||michalbliznak||Owned by:||vadz|
Inconsistent font encoding is used in wxTextCtrl::LoadFile() a wxTextCtrl::SaveFile() functions (at least) on Windows.
When a text content from a text control is saved to a file via wxTextCtrl::SaveText() function then local (current) font encoding is used (in my case it is WINDOWS-1250), but when loaded back to the text control via wxTextCtrl::LoadFile() function, then the non-ascii text is corrupted. IMHO it is caused by inconsistent calls to wxFFile::ReadAll() and wxFFile::Write() functions in textcmn.cpp where the first one uses default wxConvAuto values while the second one uses *wxConvCurrent. On my system, the system font encoding is really Windows-1250 while the default font encoding from fallback mode defined in wxConvAuto is ISO-8859-1. The workaround for this issue is to set proper fallback encoding, i.e. to call:
wxConvAuto::SetFallbackEncoding( wxLocale::GetSystemEncoding() );
Of course, the problem can be more serious and it could be burried somewhere deeper in wxWidgets...