Qt-interest Archive, August 2007
QSvgGenerator will not output UTF-8 files on Windows
Message 1 in thread
Hi all,
I am having a problem with QSvgGenerator. I have a subclassed QGraphicsView
that I use to draw a few things, also occasionally some text that can
contain non-ASCII characters such as "ÂC" or "mÂ". Then, I want to render
this with QSvgGenerator so that it spits out a SVG file.
On Linux it works fine. The resulting file is accepted by Inkscape and works
without a glitch.
On Windows, Inkscape rejects the file (without giving a hint on why, I might
add). Upon inspection, I noticed that is because the file is in Latin-1 and
not UTF-8. The Latin-1 file will not be read in either Linux or Windows.
However, if I run:
$ recode Latin-1..UTF-8 badfile.svg
the file becomes accessible with Inkscape.
I am not sure whether this is a Qt problem or simply my configuration
problem (I should tell Windows to use UTF-8 as default, maybe? How so?)
In short, how do I convince QSvgGenerator to output files in UTF-8? I
thought of QLocale, but there is nothing there about the charset. Any
ideas?
Cheers,
-Federico
--
[ signature omitted ]
Message 2 in thread
Federico Zenith wrote:
> [...]
> In short, how do I convince QSvgGenerator to output files in UTF-8? I
> thought of QLocale, but there is nothing there about the charset. Any
> ideas?
Of course, after having tried to find a solution all day, I find it ten
minutes after posting... for those interested, the solution (at least the
one that works for me) is to add:
QTextCodec::setCodecForLocale( QTextCodec::codecForName( "UTF-8" ) );
somewhere in main.cpp before the main window application is fired up.
Cheers,
-Federico
--
[ signature omitted ]