[webkit-help] How can I write content of a TextRun to a file
julien.chaffraix at gmail.com
Sun Jan 17 12:23:59 PST 2010
> I have a TextRun object and I would like to write the characters
> between 'from' and 'to'
> writeToFile(const TextRun& run, int from, int to)
> Can you please tell me how can I do that?
> I get a UChar* from run.characters() But how can I write it to a file?
You can convert it to some encoding that you can dump as char* such as
latin1 or utf8:
String characters = run.characters().substring(from, to - from);
CString charactersUTF8 = characters.utf8(); // Or .latin1().
std::cout << charactersUTF8.data() << std::endl; // Print the results
but you can use a stream to a file or fwrite as it as char*.
If you want to avoid encoding conversion or the overhead of creating a
String and a CString, you will have to look at the ICU documentation
(though you could use the same magic as in
to dump your UChar*).
More information about the webkit-help