Aloha, I'm trying to save UTF8 encoded HTML:
String word = textWord->getText().trim(); String dictUrl = "http://de.thefreedictionary.com/p/" + word; URL url(dictUrl); String path = File::getCurrentWorkingDirectory().getFullPathName() + "/" + word + ".html"; File file(path); FileOutputStream out(file); out.writeText(url.readEntireTextStream(), false, false); // save as UTF-8 ? // out.writeString(url.readEntireTextStream()); // tried this too out.flush();
Alas, when I open the file (in Internet Explorer 9, Win7 x64), the characters don't display properly. However, if I load the contents from URL::readEntireTextStream() into a TextEditor, then right-click/copy/paste into Notepad++ and choose Encoding->Encode in UTF-8, I can save the file and re-open it in IE9, and it displays as expected.
I've lurked a bit on the forums and grokked some of the source, and my understanding is that:
1) the internal String representation is UTF8 by default
2) OutputStream::writeText() saves the String as UTF8 or UTF16, depending on parameters
What am I missing? Thanks in advance.