Understand. Anyway, in Teapot it should possible to set the UTF-8 charset for JSON documents.

Thanks,
Volkert

Am 02.05.2015 um 20:34 schrieb Sven Van Caekenberghe:
Hi Volkert,

Thanks for the test case, it helped me figure out what the problem was.

Basically, what Norbert said was 100% correct: the server code (Teapot) should 
have specified the charset or encoding of the mime-type it was using (so 
application/json;charset=utf-8 instead of just application/json).

However, I thought I had changed the default to be utf-8, so I was surprised it 
was not picked up.

It turned out utf-8 was the default for reading/writing http messages and their 
entities, but not so when manually constructing instances (like Teapot did).

In code,

json := '{''bank'':''Région Genève Rhône''}'.
entity := ZnEntity with: json type: 'application/json'.
response := ZnResponse ok: entity.
response encoder.

did not return a ZnUTF8Encoder but a ZnNullEncoder.

I changed that now.

===
Name: Zinc-HTTP-SvenVanCaekenberghe.428
Author: SvenVanCaekenberghe
Time: 2 May 2015, 7:09:55.832482 pm
UUID: 6376bd91-2a95-4265-bfff-e3c6626aee79
Ancestors: Zinc-HTTP-SvenVanCaekenberghe.427

Change ZnStringEntity>>#initializeEncoder to default to ZnUTF8Encoder unless 
ZnDefaultCharacterEncoder is set

Change ZnEntityReader>>#readEntity to no longer use #withDefaultUtf8Decoder: 
(and remove it)

Change ZnEntityWriter>>#writeEntity: to no longer use #withDefaultUtf8Encoder: 
(and remove it)

Add ZnResponseTests>>#testDefaultUTF8Encoding
===
Name: Zinc-Tests-SvenVanCaekenberghe.226
Author: SvenVanCaekenberghe
Time: 2 May 2015, 7:10:12.331593 pm
UUID: 9010fbd6-bf9d-400e-b463-cb73920b79f6
Ancestors: Zinc-Tests-SvenVanCaekenberghe.225

Change ZnStringEntity>>#initializeEncoder to default to ZnUTF8Encoder unless 
ZnDefaultCharacterEncoder is set

Change ZnEntityReader>>#readEntity to no longer use #withDefaultUtf8Decoder: 
(and remove it)

Change ZnEntityWriter>>#writeEntity: to no longer use #withDefaultUtf8Encoder: 
(and remove it)

Add ZnResponseTests>>#testDefaultUTF8Encoding
===

for now, in #bleedingEdge of Zinc HTTP Components.

HTH,

Sven



Reply via email to