PDA

View Full Version : How to save a file in UTF with BOM?



Alan_K
19th March 2011, 20:35
QTextCodec::setCodecForCStrings(QTextCodec::codecF orName("UTF-8"));
QTextCodec::setCodecForLocale(QTextCodec::codecFor Name("UTF-8"));
QTextCodec::setCodecForTr(QTextCodec::codecForName ("UTF-8"));

Is not working. How to save a file in UTF-8 with BOM. :confused:

schnitzel
19th March 2011, 20:47
what exactly is BOM?

Alan_K
19th March 2011, 20:56
My program generates a HTML file in UTF-8 format. I want to later edit this file in notepad++, but it must be in UTF-8 with BOM (http://en.wikipedia.org/wiki/Byte-order_mark). This will allow me on Polish characters.

schnitzel
19th March 2011, 21:00
do you get the correct encoding disregarding the BOM?
can you put the BOM in manually?

Alan_K
19th March 2011, 21:10
do you get the correct encoding disregarding the BOM?
Yep, I have UTF-8.


can you put the BOM in manually?
Yes, but I want it to be automatic.

Octal
19th March 2011, 21:19
You are maybe looking for QTextStream::setGenerateByteOrderMark (http://doc.qt.nokia.com/latest/qtextstream.html#setGenerateByteOrderMark)

Alan_K
19th March 2011, 21:32
That's it. Works, thanks. :p