<?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[Boost json und UTF8]]></title><description><![CDATA[<p>Nachfogend ein JSON File &lt;file.json&gt;, welches UTF8 Zeichen enthält:</p>
<pre><code class="language-cpp">{
  &quot;description&quot;: &quot;\u00FCber den Wolken muss...&quot;,
}
</code></pre>
<p>Wie kann ich nachfolgenden Code ändern, dass der JSON Parser von BOOST auch UTF8 liest?</p>
<pre><code class="language-cpp">#include &quot;boost/property_tree/json_parser.hpp&quot;

void F()
{
    boost::property_tree::ptree pt;
    boost::property_tree::json_parser::read_json(file.json, pt);
    boost::optional&lt;std::string&gt; optional = pt.get_optional&lt;std::string&gt;(&quot;description&quot;);
    if (optional)
    {
        std::string info = *optional;
        // more code...
    }
}
</code></pre>
<p>Danke für eure Hilfe!<br />
Gruß,<br />
T.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/307873/boost-json-und-utf8</link><generator>RSS for Node</generator><lastBuildDate>Thu, 06 Aug 2026 08:46:04 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/307873.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 07 Sep 2012 13:14:13 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Boost json und UTF8 on Fri, 07 Sep 2012 13:14:13 GMT]]></title><description><![CDATA[<p>Nachfogend ein JSON File &lt;file.json&gt;, welches UTF8 Zeichen enthält:</p>
<pre><code class="language-cpp">{
  &quot;description&quot;: &quot;\u00FCber den Wolken muss...&quot;,
}
</code></pre>
<p>Wie kann ich nachfolgenden Code ändern, dass der JSON Parser von BOOST auch UTF8 liest?</p>
<pre><code class="language-cpp">#include &quot;boost/property_tree/json_parser.hpp&quot;

void F()
{
    boost::property_tree::ptree pt;
    boost::property_tree::json_parser::read_json(file.json, pt);
    boost::optional&lt;std::string&gt; optional = pt.get_optional&lt;std::string&gt;(&quot;description&quot;);
    if (optional)
    {
        std::string info = *optional;
        // more code...
    }
}
</code></pre>
<p>Danke für eure Hilfe!<br />
Gruß,<br />
T.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2249388</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2249388</guid><dc:creator><![CDATA[Tomahawk]]></dc:creator><pubDate>Fri, 07 Sep 2012 13:14:13 GMT</pubDate></item><item><title><![CDATA[Reply to Boost json und UTF8 on Fri, 07 Sep 2012 13:52:56 GMT]]></title><description><![CDATA[<p>Was erwartest Du, dass in <em>info</em> steht und was steht tatsächlich drin?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2249403</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2249403</guid><dc:creator><![CDATA[theta]]></dc:creator><pubDate>Fri, 07 Sep 2012 13:52:56 GMT</pubDate></item><item><title><![CDATA[Reply to Boost json und UTF8 on Fri, 07 Sep 2012 14:03:16 GMT]]></title><description><![CDATA[<p>Der Umlaut (hier &quot;ü&quot;) sollte auch so im std::string stehen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2249405</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2249405</guid><dc:creator><![CDATA[Tomahawk]]></dc:creator><pubDate>Fri, 07 Sep 2012 14:03:16 GMT</pubDate></item><item><title><![CDATA[Reply to Boost json und UTF8 on Fri, 07 Sep 2012 15:00:50 GMT]]></title><description><![CDATA[<p>ü (U+00FC) wird ja in UTF-8 als Sequenz aus zwei Bytes, nämlich <code>0xc3</code> und <code>0xbc</code> , codiert. Falls also <code>0xc3</code> , <code>0xbc</code> in deinem <code>std::string</code> stehen, ist es korrekt eingelesen.</p>
<p>Jetzt stellt sich die Frage der Darstellung:<br />
Der Visual Studio Debugger z.B. zeigt dir nicht ü, sondern kryptische Zeichen an, eben die Enstprechung von <code>0xc3</code> und <code>0xbc</code> an (als je einen Charakter).</p>
<p>Könnte sein, dass alles richtig ist, Du jedoch mit einem anderen Ergebnis gerechnet hast...</p>
<p>Hier noch eine UTF-8 Tabelle: <a href="http://www.utf8-chartable.de/" rel="nofollow">http://www.utf8-chartable.de/</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2249414</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2249414</guid><dc:creator><![CDATA[theta]]></dc:creator><pubDate>Fri, 07 Sep 2012 15:00:50 GMT</pubDate></item></channel></rss>