<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Efficy Overflow Q&amp;A - Recent questions tagged windows-1252</title>
<link>https://overflow.efficy.io/?qa=tag/windows-1252</link>
<description>Powered by Question2Answer</description>
<item>
<title>How to convert windows 1252 to UTF-8 ?</title>
<link>https://overflow.efficy.io/?qa=6592/how-to-convert-windows-1252-to-utf-8</link>
<description>&lt;p&gt;Hello,&lt;/p&gt;

&lt;p&gt;I'm running into an issue regarding char encoding.&lt;/p&gt;

&lt;p&gt;I'm making a Efficy.openUrlSecure(...) POST call to send JSON data to another system.&lt;br&gt;
Data is from a Contact (name, firstname, email, ....) and my call is made in a afterCommit workflow. So all data is taken from database.&lt;/p&gt;

&lt;p&gt;If I use a special char like &quot;é&quot; in sent data, the API send me an error :&lt;br&gt;
&lt;em&gt;Error 400. Response : Invalid UTF-8 middle byte 0x22 at...&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Code used :&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;var toSend = JSON.stringify(data);
var headers = [&quot;Content-Type: application/json;charset=utf-8&quot;, &quot;Content-Length: &quot; + toSend.length, &quot;Host: xxx&quot;];

var response = Efficy.openUrlSecure(url, toSend, headers.join(&quot;\n&quot;), &quot;POST&quot;);
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;After investigation, this error is caused by an invalid/illegal encoding (windows 1252 instead of UTF-8 which is standard for JSON).&lt;/p&gt;

&lt;p&gt;When I check in detail what is sent, the request payload is in windows-1252.&lt;/p&gt;

&lt;p&gt;Which brings it to my question : How can I convert my data in windows-1252 to UTF-8 without losing accentuated char ?&lt;/p&gt;
</description>
<category>WorkFlow / Serverscript</category>
<guid isPermaLink="true">https://overflow.efficy.io/?qa=6592/how-to-convert-windows-1252-to-utf-8</guid>
<pubDate>Fri, 10 Jun 2022 09:44:52 +0000</pubDate>
</item>
</channel>
</rss>