[webkit-help] How can I write content of a TextRun to a file
Julien Chaffraix
julien.chaffraix at gmail.com
Sun Jan 17 12:23:59 PST 2010
Hi,
> 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
http://source.icu-project.org/repos/icu/icu/trunk/source/samples/ustring/ustring.cpp
to dump your UChar*).
Regards,
Julien
More information about the webkit-help
mailing list