Detection of code pages
C / C++ / MFC
1
Posts
1
Posters
0
Views
1
Watching
-
Hi all. Has anyone any ideas on how to detect (programatically) the code page of a text file in Win32? At least in a way that makes the correct guess 90 % of the time? For now, I'm testing different code pages with MultiByteToWideChar (CP_ANSI - CP_UTF8), counting the number of letters in the string (using iswalpha), and then the code page with the most letters wins. Feels shaky. This problem must have been around for ever, but I can't find any good ideas on how to deal with it. Btw, there's a function called IsTextUnicode in the NLS API, does anyone know how to use it on reversed (MacOS) Unicode-files? I've tried the XXX_REVERSED flags, but the stupid function returns zero for every kind of input. Any help or clues would be appreciated.