<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Pain and insanity: Unicode filenames and Qt]]></title><description><![CDATA[<p dir="auto">I'm going bonkers here.<br />
I am using PySide (tried PyQt also) but I can't possibly get QFile to open a file when the filename contains unicode characters (e.g. <em>"/home/user/þæö.txt"</em> ).<br />
<em>QFile.open</em> always returns False on these kind of files, but works fine when the name only contains ASCII characters.<br />
Python's <em>open()</em> function also works fine for the unicode filenames.</p>
<p dir="auto">I've tried mangling the filename in every way I know, decoding it to utf8, encoding it into a bytestring and whatever. But no avail.<br />
Havin run this with strace I realized that what Qt is doing is that it simply strips all the unicode characters from the filename before calling the system's <em>open()</em> function, so it's really just trying to open a non-existing file.</p>
<p dir="auto">I made this script to demonstrate the problem <a href="http://pastebin.com/rKCkeJNQ" target="_blank" rel="noopener noreferrer nofollow ugc">http://pastebin.com/rKCkeJNQ</a><br />
If you guys don't mind, I would appreciate if you could run it and see if you get the same result, to see if this is some problem with my system.<br />
All it does is create a couple of empty files in your system's temp directory and then try to open them with Qt, printing the result to console.</p>
<p dir="auto">Thanks for reading.</p>
]]></description><link>https://forum.qt.io/topic/24158/pain-and-insanity-unicode-filenames-and-qt</link><generator>RSS for Node</generator><lastBuildDate>Wed, 15 Apr 2026 03:07:38 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/24158.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 11 Feb 2013 15:07:10 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Pain and insanity: Unicode filenames and Qt on Tue, 12 Feb 2013 11:11:06 GMT]]></title><description><![CDATA[<p dir="auto">Lots of fixes in that area have gone into Qt4.8, are you using that (or newer) ?</p>
<p dir="auto">It might also be good to check what the encoding is of the file on your filesystem. If you use Windows, it likely is not utf8.  If you use Linux, its a 50% chance being utf8 or some other encoding.</p>
]]></description><link>https://forum.qt.io/post/166885</link><guid isPermaLink="true">https://forum.qt.io/post/166885</guid><dc:creator><![CDATA[tzander]]></dc:creator><pubDate>Tue, 12 Feb 2013 11:11:06 GMT</pubDate></item><item><title><![CDATA[Reply to Pain and insanity: Unicode filenames and Qt on Tue, 12 Feb 2013 07:53:06 GMT]]></title><description><![CDATA[<p dir="auto">FromLocal8Bit is what you usually want: It should transcode your local encoding to unicode. This requires your system to be set up correctly though: If your local encoding is set incorrectly the transformation will indeed fail.</p>
]]></description><link>https://forum.qt.io/post/166858</link><guid isPermaLink="true">https://forum.qt.io/post/166858</guid><dc:creator><![CDATA[tobias.hunger]]></dc:creator><pubDate>Tue, 12 Feb 2013 07:53:06 GMT</pubDate></item><item><title><![CDATA[Reply to Pain and insanity: Unicode filenames and Qt on Mon, 11 Feb 2013 16:33:36 GMT]]></title><description><![CDATA[<p dir="auto">I was crawling through the Qt source code and it looks the filename is always passed through this function in corelib/io/qfile.cpp on unix</p>
<p dir="auto">@<br />
static QString locale_decode(const QByteArray &amp;f)<br />
{<br />
#if defined(Q_OS_DARWIN)<br />
// Mac always gives us UTF-8 and decomposed, we want that composed...<br />
return QString::fromUtf8(f).normalized(QString::NormalizationForm_C);<br />
#elif defined(Q_OS_SYMBIAN)<br />
return QString::fromUtf8(f);<br />
#else<br />
return QString::fromLocal8Bit(f);<br />
#endif<br />
}<br />
@</p>
<p dir="auto">SO it's always giving me the "fromLocal8Bit" value of the string.<br />
Which results in unicode characters being stripped from the filename.</p>
<p dir="auto">What to do with this information, I'm not sure yet.</p>
]]></description><link>https://forum.qt.io/post/166782</link><guid isPermaLink="true">https://forum.qt.io/post/166782</guid><dc:creator><![CDATA[elgur]]></dc:creator><pubDate>Mon, 11 Feb 2013 16:33:36 GMT</pubDate></item></channel></rss>