I have one file that is encoded in ANSI format (showing in Notepad++ as Encoded in ANSI) and it also shows the special characters (degree celcius,pound etc.) and while reading i want to convert all the characters to unicode.
How can i convert ANSI to Unicode in C/C++ or Qt ?
My Qt is still very rusty, but something along the following lines:
Pieced together from the documentation of
QFileandQTextStream, both of which include examples for reading and writing files. The default forQTextStreamis to use the legacy encoding, so we only need to set an explicit encoding on the outputQTextStream.If the file isn’t too large you could probably also use
instead of the loop over the lines. The loop especially might add a trailing line break to the output file (although the docs aren’t very clear on that).