<div dir="ltr">Hi Sven.<div><br></div><div>I&#39;ve had a problem when POSTing non-ascii UTF-8 characters in JSON to Seaside REST service. I&#39;ve located the problem in the method ZnZincServerAdaptor&gt;&gt;requestBodyFor: where the body of ZnRequest is translated to body of WARequest. I use Pharo 1.4 with Seaside 3.0.8 and Zinc-Seaside-SvenVanCaekenberghe.40.</div>


<div><br></div><div>When the POSTed JSON contains non-ascii UTF-8 characters (Czech characters), they are corrupted. The problem is on the &quot;MARKED&quot; line, where the array of bytes changed to string by asString.</div>
<div>
<br></div><div>&quot;Problematic&quot; code:</div><div><br></div><div><font face="courier new, monospace">ZnZincServerAdaptor&gt;&gt;requestBodyFor: aZincRequest</font></div>
<div><font face="courier new, monospace"><span style="white-space:pre-wrap">        </span>^ (aZincRequest method ~= #TRACE </font></div><div><font face="courier new, monospace"><span style="white-space:pre-wrap">                </span>and: [ aZincRequest hasEntity</font></div>

<div><font face="courier new, monospace"><span style="white-space:pre-wrap">                        </span>and: [ aZincRequest entity isEmpty not</font></div>
<div><font face="courier new, monospace"><span style="white-space:pre-wrap">                                </span>and: [ (aZincRequest entity contentType matches: ZnMimeType applicationFormUrlEncoded) not</font></div><div><font face="courier new, monospace"><span style="white-space:pre-wrap">                                        </span>and: [ (aZincRequest entity contentType matches: ZnMimeType multiPartFormData) not ] ] ] ])</font></div>


<div><font face="courier new, monospace"><span style="white-space:pre-wrap">                        </span>ifTrue: [</font></div><div><font face="courier new, monospace"><span style="white-space:pre-wrap">                                </span>&quot;Seaside wants to do its own text conversions&quot;</font></div>

<div><font face="courier new, monospace"><span style="white-space:pre-wrap">                                </span>aZincRequest entity bytes asString &quot;MARKED&quot; ]</font></div>
<div><font face="courier new, monospace"><span style="white-space:pre-wrap">                        </span>ifFalse: [</font></div><div><font face="courier new, monospace"><span style="white-space:pre-wrap">                                </span>String new ]</font></div>

<div><br></div><div>I did a quick correction, which is not nice, but works for me:</div><div><br></div><div><div><font face="courier new, monospace">ZnZincServerAdaptor&gt;&gt;requestBodyFor: aZincRequest</font></div><div>
<font face="courier new, monospace"><span style="white-space:pre-wrap">        </span>^ (aZincRequest method ~= #TRACE </font></div>
<div><font face="courier new, monospace"><span style="white-space:pre-wrap">                </span>and: [ aZincRequest hasEntity</font></div><div><font face="courier new, monospace"><span style="white-space:pre-wrap">                        </span>and: [ aZincRequest entity isEmpty not</font></div>
<div><font face="courier new, monospace"><span style="white-space:pre-wrap">                                </span>and: [ (aZincRequest entity contentType matches: ZnMimeType applicationFormUrlEncoded) not</font></div>
<div><font face="courier new, monospace"><span style="white-space:pre-wrap">                                        </span>and: [ (aZincRequest entity contentType matches: ZnMimeType multiPartFormData) not ] ] ] ])</font></div><div><font face="courier new, monospace"><span style="white-space:pre-wrap">                        </span>ifTrue: [</font></div>
<div><font face="courier new, monospace"><span style="white-space:pre-wrap">                                </span>&quot;Seaside wants to do its own text conversions&quot;</font></div>
<div><font face="courier new, monospace"><span style="white-space:pre-wrap">                                </span><span style="white-space:pre-wrap">ZnUTF8Encoder new decodeBytes: </span>aZincRequest entity bytes &quot;CORRECTED&quot; ]</font></div>
<div><font face="courier new, monospace"><span style="white-space:pre-wrap">                        </span>ifFalse: [</font></div><div><font face="courier new, monospace"><span style="white-space:pre-wrap">                                </span>String new ]</font></div>

</div><div><br></div><div>My correction tries to decode byte array with ZnUTF8Encoder and the result is OK.</div><div><br></div><div>Maybe I would re<font face="arial, helvetica, sans-serif">commend to use GRPharoUtf8Codec (although I like ZnUTF8Encoder more) or even better self codec (self = ZnZincServerAdaptor) to try to decode the bytes.</font></div>
<div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">Regards,</font></div><div><font face="arial, helvetica, sans-serif">Tomas Kukol</font></div></div>