<?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[Qt MS Access umlauts]]></title><description><![CDATA[<p dir="auto">Hi</p>
<p dir="auto">I have an MS Access database with two tables: test, Test_utf8 (see images below)</p>
<p dir="auto">The data in the column example of table test was entered directly in MS Access. The data in Test_utf8 was imported from a text file with utf-8 encoding.</p>
<p dir="auto"><img src="https://ddgobkiprc33d.cloudfront.net/e0db83dd-373e-43e0-ab14-aeba6f55fc7e.png" alt="b972ecab-66c5-4c2f-8fe6-6a30bf3c5e6f-grafik.png" class=" img-fluid img-markdown" /> ![alt text](image url)</p>
<p dir="auto"><img src="https://ddgobkiprc33d.cloudfront.net/8d90e630-5f70-4616-ba25-74cbcd3c4f00.png" alt="40b64097-40fd-4dd7-b64a-e959a7f19095-grafik.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">The code is as follows:</p>
<pre><code>QSqlDatabase db = QSqlDatabase::addDatabase("QODBC3");
QString connString = "DBQ=umlaute.mdb;Driver={Microsoft Access Driver (*.mdb,*.accdb)};FIL={MS Access};"
QSqlQuery query;
QString sql_statement = "SELECT example FROM test;" //or "SELECT example_utf8 FROM Test_utf8"

db.setDatabaseName(connString);
if (db.open()) {
    QFile file("output.txt");
    if(file.open(QFile::WriteOnly)) {
        QTextStream out(&amp;file);
        out.setCodec("windows-1252") // or "UTF-8" if Test_utf8
        query.prepare(sql_statement);
        query.exec();
        while (query.next()) {
            qDebug() &lt;&lt; query.value(0).toByteArray();
            out &lt;&lt; query.value(0).toByteArray() &lt;&lt; " | " &lt;&lt; QString::fromUtf8(query.value(0).toByteArray()) &lt;&lt; " | " ;                                                    
            out &lt;&lt; QString::fromLatin1(query.value(0).toByteArray()) &lt;&lt; " | ";
            out &lt;&lt; query.value(0).toByteArray().toHex(' ') &lt;&lt; Qt::endl;
        }
    }
}
else {
    qDebug() &lt;&lt; "could not open database";
    qDebug() &lt;&lt; db.lastError();
}

db.close();
</code></pre>
<p dir="auto">When I try to query the data  I get different results depending on which table i am querying.</p>
<p dir="auto">Example for the word "hellö"<br />
When querying table test I get: <img src="https://ddgobkiprc33d.cloudfront.net/48ea4069-ba23-4623-8254-8b1f4a1207bd.png" alt="78b959f4-7ec6-42ca-bf93-33c5592c95ff-grafik.png" class=" img-fluid img-markdown" /> which is a replacement character and my guess is it indicates an encoding problem.</p>
<p dir="auto">With table Test_utf8 I get:<img src="https://ddgobkiprc33d.cloudfront.net/62cbbab3-942b-44df-8a4d-f1a44ef0c405.png" alt="396d9811-e0b7-48f1-9fee-29d9047ad58f-grafik.png" class=" img-fluid img-markdown" />  which corresponds to an "ö"</p>
<p dir="auto">I am however at a loss as to how to get the "ö" when querying table test. Any help, suggestions or ideas would by much appreciated.</p>
<p dir="auto">Cheers</p>
<p dir="auto">PS: I am using Qt 5.15.0 MinGW 64-bit, the 64-bit Microsoft Access Driver (*mdb,*accdb) and the database was created with 64-bit MS Access</p>
]]></description><link>https://forum.qt.io/topic/138397/qt-ms-access-umlauts</link><generator>RSS for Node</generator><lastBuildDate>Sun, 03 May 2026 13:17:29 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/138397.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 05 Aug 2022 10:08:08 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Qt MS Access umlauts on Thu, 11 Aug 2022 06:10:09 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/hskoglund">@<bdi>hskoglund</bdi></a> using odbc2 did not make a difference. technically switching the unicode settings on my PC worked but a whole lot of other problems with other software arose. So I switched it back.</p>
<p dir="auto">I did find this in the documentation (<a href="https://doc.qt.io/qt-6/qsqlquery.html" target="_blank" rel="noopener noreferrer nofollow ugc">https://doc.qt.io/qt-6/qsqlquery.html</a>):<br />
<img src="https://ddgobkiprc33d.cloudfront.net/cff48ee6-7170-4ca6-8c44-3f30c77e85e5.png" alt="d52de0e0-14c5-45e7-8490-6087d665f701-grafik.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">So I moved the query to after if(db.open()), as shown below</p>
<pre><code>QSqlDatabase db = QSqlDatabase::addDatabase("QODBC3");
QString connString = "DBQ=umlaute.mdb;Driver={Microsoft Access Driver (*.mdb,*.accdb)};FIL={MS Access};"
QString sql_statement = "SELECT example FROM test;" //or "SELECT example_utf8 FROM Test_utf8"

db.setDatabaseName(connString);
if (db.open()) {
    QSqlQuery query; //moved query to here
    QFile file("output.txt");
    if(file.open(QFile::WriteOnly)) {
        QTextStream out(&amp;file);
        out.setCodec("windows-1252") // or "UTF-8" if Test_utf8
        query.prepare(sql_statement);
        query.exec();
        while (query.next()) {
            qDebug() &lt;&lt; query.value(0).toByteArray();
            out &lt;&lt; query.value(0).toByteArray() &lt;&lt; " | " &lt;&lt; QString::fromUtf8(query.value(0).toByteArray()) &lt;&lt; " | " ;                                                    
            out &lt;&lt; QString::fromLatin1(query.value(0).toByteArray()) &lt;&lt; " | ";
            out &lt;&lt; query.value(0).toByteArray().toHex(' ') &lt;&lt; Qt::endl;
        }
    }
}
else {
    qDebug() &lt;&lt; "could not open database";
    qDebug() &lt;&lt; db.lastError();
}

db.close();
</code></pre>
<p dir="auto">Now i get <img src="https://ddgobkiprc33d.cloudfront.net/0af3f78a-723f-491f-8aca-df3e65e7f689.png" alt="4a5368f4-f9fc-4684-b4a6-15f8e3dd9d4a-grafik.png" class=" img-fluid img-markdown" /><br />
when querying table test, which is correct.</p>
<p dir="auto">Thank you for your time and help!</p>
]]></description><link>https://forum.qt.io/post/724481</link><guid isPermaLink="true">https://forum.qt.io/post/724481</guid><dc:creator><![CDATA[mki2]]></dc:creator><pubDate>Thu, 11 Aug 2022 06:10:09 GMT</pubDate></item><item><title><![CDATA[Reply to Qt MS Access umlauts on Tue, 09 Aug 2022 07:18:48 GMT]]></title><description><![CDATA[<p dir="auto">Aha, now i recognize that � (ef bf bd). I remember for example <a href="https://forum.qt.io/topic/61390/qodbc-and-utf-8-issues">this post</a> which had more or less the same problem. I used a workaround (bypassing Qt's ODBC driver + talking directly to ODBC) I have the code somewhere but I ditched GitHub when Microsoft bought it so the link doesn't work.</p>
<p dir="auto">Here's some stuff you could try:<br />
Try using ODBC2 instead of 3:<br />
QSqlDatabase::addDatabase("QODBC");</p>
<p dir="auto">Try changing the Unicode settings in your Windows PC<br />
<a href="https://stackoverflow.com/a/69268839/233402" target="_blank" rel="noopener noreferrer nofollow ugc">https://stackoverflow.com/a/69268839/233402</a></p>
]]></description><link>https://forum.qt.io/post/724192</link><guid isPermaLink="true">https://forum.qt.io/post/724192</guid><dc:creator><![CDATA[hskoglund]]></dc:creator><pubDate>Tue, 09 Aug 2022 07:18:48 GMT</pubDate></item><item><title><![CDATA[Reply to Qt MS Access umlauts on Tue, 09 Aug 2022 04:59:12 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/hskoglund">@<bdi>hskoglund</bdi></a></p>
<p dir="auto">This is what I get:</p>
<p dir="auto"><img src="https://ddgobkiprc33d.cloudfront.net/73eab959-e26a-4fe4-93d0-f2c0d33f42d6.png" alt="e1d184e1-a6af-4ee6-9cfb-0f66ee2c8eeb-grafik.png" class=" img-fluid img-markdown" /></p>
<p dir="auto"><img src="https://ddgobkiprc33d.cloudfront.net/9cd7e97a-6542-48fa-bce0-43852ec23428.png" alt="a769092f-56ad-4f9b-8d00-a2d317b139ae-grafik.png" class=" img-fluid img-markdown" /></p>
]]></description><link>https://forum.qt.io/post/724184</link><guid isPermaLink="true">https://forum.qt.io/post/724184</guid><dc:creator><![CDATA[mki2]]></dc:creator><pubDate>Tue, 09 Aug 2022 04:59:12 GMT</pubDate></item><item><title><![CDATA[Reply to Qt MS Access umlauts on Tue, 09 Aug 2022 00:35:10 GMT]]></title><description><![CDATA[<p dir="auto">If you try a hex dump, say like:<br />
<code>qDebug() &lt;&lt; query.value(0).toByteArray().toHex(' ');</code><br />
can you see the Windows-1252 characters (i.e. the ones bigger than 0x7f)?</p>
]]></description><link>https://forum.qt.io/post/724178</link><guid isPermaLink="true">https://forum.qt.io/post/724178</guid><dc:creator><![CDATA[hskoglund]]></dc:creator><pubDate>Tue, 09 Aug 2022 00:35:10 GMT</pubDate></item><item><title><![CDATA[Reply to Qt MS Access umlauts on Mon, 08 Aug 2022 12:43:49 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/hskoglund">@<bdi>hskoglund</bdi></a> I tried that. But it doesn't seem to me that it solves the problem. I modified my code above to output a txt. here is what I get when querying table test</p>
<p dir="auto"><img src="https://ddgobkiprc33d.cloudfront.net/9a53ffaa-ddfc-4ab6-a16f-402ffdc70aec.png" alt="546faeee-7f6a-44ae-9d38-2d6ab924d6a9-grafik.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">and this is what I get when I query table Test_utf8:</p>
<p dir="auto"><img src="https://ddgobkiprc33d.cloudfront.net/1c23176f-6d0e-48b8-988d-859f3a42253a.png" alt="ab564963-906d-4865-aa29-2933f993e8c2-grafik.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">I think regarding Test_utf8 the output is as expected.<br />
However, regarding table test the "information" is "lost" upon being read from the database?</p>
]]></description><link>https://forum.qt.io/post/724144</link><guid isPermaLink="true">https://forum.qt.io/post/724144</guid><dc:creator><![CDATA[mki2]]></dc:creator><pubDate>Mon, 08 Aug 2022 12:43:49 GMT</pubDate></item><item><title><![CDATA[Reply to Qt MS Access umlauts on Mon, 08 Aug 2022 11:23:42 GMT]]></title><description><![CDATA[<p dir="auto">Hi, you could also try converting from -1252:<br />
qDebug() &lt;&lt; QString::fromLatin1(query.value(0).toByteArray())</p>
]]></description><link>https://forum.qt.io/post/724134</link><guid isPermaLink="true">https://forum.qt.io/post/724134</guid><dc:creator><![CDATA[hskoglund]]></dc:creator><pubDate>Mon, 08 Aug 2022 11:23:42 GMT</pubDate></item><item><title><![CDATA[Reply to Qt MS Access umlauts on Mon, 08 Aug 2022 11:18:39 GMT]]></title><description><![CDATA[<p dir="auto">Thanks for the replies!<br />
So it is an encoding issue.<br />
I tried <a class="plugin-mentions-user plugin-mentions-a" href="/user/hskoglund">@<bdi>hskoglund</bdi></a>  suggestion, but it doesn't change the output result. I still get: <img src="https://ddgobkiprc33d.cloudfront.net/2135b013-07f4-454f-beaa-235be93db8c9.png" alt="2813417c-792c-4896-a0da-4f8d3a13e964-grafik.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">adding the following into the while loop:</p>
<pre><code>qDebug() &lt;&lt; "output variant: " &lt;&lt; query.value(0);
</code></pre>
<p dir="auto">already yields: <img src="https://ddgobkiprc33d.cloudfront.net/b441afbf-cf84-40c2-8486-5d0c51cfd5f4.png" alt="05105fa2-727f-4be1-b859-c32f2bb15650-grafik.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">so i would need to specify the encoding before the query is executed? How could I do this?<br />
As far as I am aware I can't specify an encoding, e.g. charset="Windows-1252" in the connection string for odbc and ms access.</p>
<p dir="auto">The actual ms access database I will have to work with will unfortunately be like table test and not like table Test_utf8. I just wanted to see what result I get when I am sure the data in the field is utf-8 encoded.</p>
]]></description><link>https://forum.qt.io/post/724131</link><guid isPermaLink="true">https://forum.qt.io/post/724131</guid><dc:creator><![CDATA[mki2]]></dc:creator><pubDate>Mon, 08 Aug 2022 11:18:39 GMT</pubDate></item><item><title><![CDATA[Reply to Qt MS Access umlauts on Fri, 05 Aug 2022 12:06:03 GMT]]></title><description><![CDATA[<p dir="auto">To add to <a class="plugin-mentions-user plugin-mentions-a" href="/user/chrisw67">@<bdi>ChrisW67</bdi></a>: you could try converting from UTF-8, say like this:</p>
<pre><code>...
query.exec();
    while (query.next()) {
        qDebug() &lt;&lt; QString::fromUtf8(query.value(0).toByteArray());
    }
...
</code></pre>
]]></description><link>https://forum.qt.io/post/723930</link><guid isPermaLink="true">https://forum.qt.io/post/723930</guid><dc:creator><![CDATA[hskoglund]]></dc:creator><pubDate>Fri, 05 Aug 2022 12:06:03 GMT</pubDate></item><item><title><![CDATA[Reply to Qt MS Access umlauts on Fri, 05 Aug 2022 11:36:00 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mki2">@<bdi>mki2</bdi></a> said in <a href="/post/723913">Qt MS Access umlauts</a>:</p>
<blockquote>
<p dir="auto">When querying table test I get:  'hell\xEF\xBF\xBD" which is a replacement character and my guess is it indicates an encoding problem.</p>
</blockquote>
<p dir="auto">Those three bytes are the UTF-8 encoding of the Unicode U+FFFD used to replace an incoming character whose value is unknown or unrepresentable in Unicode.   My guess is that the data in the column is encoded in <a href="https://en.wikipedia.org/wiki/Windows-1252#Codepage_layout" target="_blank" rel="noopener noreferrer nofollow ugc">Windows-1252</a>, that is a bare 0xF6 byte to represent the 'ö' character.</p>
<p dir="auto">A single 0xF6 byte does, indeed, make no sense if you try to <a href="https://en.wikipedia.org/wiki/UTF-8#Codepage_layout" target="_blank" rel="noopener noreferrer nofollow ugc">interpret it as UTF-8</a>.</p>
<blockquote>
<p dir="auto">With table Test_utf8 I get:  "hell\xC3\xB6" which corresponds to an "ö"</p>
</blockquote>
<p dir="auto">This is the UTF-8 encoding on the Unicode code point U+00F6 (LATIN SMALL LETTER O WITH DIAERESIS).</p>
<p dir="auto">In your shot from Access of the UTF-8 column you see these two  bytes as "Ã" and "¶" as that is what they represent in the Windows code page.</p>
]]></description><link>https://forum.qt.io/post/723927</link><guid isPermaLink="true">https://forum.qt.io/post/723927</guid><dc:creator><![CDATA[ChrisW67]]></dc:creator><pubDate>Fri, 05 Aug 2022 11:36:00 GMT</pubDate></item></channel></rss>