> I am using wxTextCtrl::LoadFile to load a list of files on a m3u file to
> a wxTextCtrl
>
> But it only works if m3u is utf-8,
This function uses wxFFile::ReadAll() internally which uses wxConvAuto to
convert the file contents to Unicode. wxConvAuto only supports Unicode
encodings in 2.8, i.e. UTF-16/32 if there is a BOM in the beginning of the
file or UTF-8 otherwise. In svn trunk it was modified to fall back to the
current (single byte) encoding if the file doesn't have BOM and isn't valid
UTF-8 but in 2.8 you will need to do it yourself, i.e. use
wxFFile::ReadAll() and wxTextCtrl::SetValue() instead of just calling
wxTextCtrl::LoadFile().
> Is there a function to know what is the encoding of a text file?
If you mean whether it's in UTF-8 or not then the simplest test is to try
to read it in UTF-8 and see if it succeeds. Chances are the file is in
UTF-8 if it does. If you mean whether it's possible to detect the file
single byte encoding (e.g. CP1252, Latin-1, KOI8-R, Shift-JIS, ...) then
the answer in general is no although there are libraries implementing some
heuristics for this.
Regards,
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/