[squeak-dev] Re: [ANN] WebClient and WebServer 1.0 for Squeak
Andreas Raab
andreas.raab at gmx.de
Mon May 10 16:52:26 UTC 2010
On 5/10/2010 5:25 AM, Hannes Hirzel wrote:
> I have a similar problem, I want to post a document to a couchDB
> instance. Without German umlauts it works fine but if I add them I get
> an error message.
>
> host :='http://localhost:5984'.
> r := WriteStream on: (String new: 1000).
> d := Dictionary new. d at: 'content' put: 'äs' squeakToUtf8.
> (JsonObject newFrom: d) jsonWriteOn: r.
> WebClient httpPut: host, '/notes/test5' content: r contents type:
> 'text/plain;charset=utf-8'.
>
> The error message of the WebResponse is
> '{"error":"bad_request","reason":"invalid UTF-8 JSON"}
> '
>
> The same thing happens if I omit #squeakToUtf8
>
> If I inspect
> r contents
> I get
> '{"content":"\uC3\uA4s"}'
^^^^^^^^^
That's interesting. If this happens when you *omit* squeakToUtf8 then
it's already being encoded:
'äs' squeakToUtf8 asByteArray hex => 'c3a473'
So 16rC3 16rA4 are the correct values for utf8-encoded 'ä'.
> How is this conversion supposed to be done?
Basically yes, but only if your input isn't already encoded. Whether
that's the case I don't know, you might check with the JSON library author.
Cheers,
- Andreas
More information about the Squeak-dev
mailing list
|