On 09 Apr 2014, at 17:29, itli...@schrievkrom.de wrote:

> The browser sends UTF8 data and in my application code I get instances
> of ZnStringEntity and the contained string is converted to (?) ISO8859-1
> (?) or CP-1252 (?). This seems to be due to the fact, that the entity
> instance always has a ZnUTF8Encoder to do the conversion.

I still don't understand the problem, but consider this:

ZnServer startDefaultOn: 1701.

ZnClient new
  url: 'http://localhost:1701/echo';
  entity: (ZnEntity with: 'An der schönen blauen Donau'); 
  post.
        
ZnClient new
  url: 'http://localhost:1701/echo';
  entity: (ZnEntity 
            with: 'An der schönen blauen Donau' 
            type: (ZnMimeType textPlain charSet: #'iso-8859-1'; yourself));
  post;
  yourself.

In the first case, a UTF-8 encoded string is POST-ed and correctly returned (in 
a UTF-8 encoded response).

In the second case, an ISO-8859-1 encoded string is POST-ed and correctly 
returned (in a UTF-8 encoded response).

In both cases the decoding was done correctly, using the specified charset (if 
that is missing, the ZnNullEncoder is used). Now, ö is not a perfect test 
example because its encoding value in Unicode, 246 decimal, U+00F6 hex, still 
fits in 1 byte and hence survives null encoding/decoding. That is why the 
following still works, although it is wrong to drop the charset.

ZnClient new
  url: 'http://localhost:1701/echo';
  entity: (ZnEntity 
            with: 'An der schönen blauen Donau' 
            type: (ZnMimeType textPlain clearCharSet; yourself));
  post;
  yourself.

HTH,

Sven



--
Sven Van Caekenberghe
http://stfx.eu
Smalltalk is the Red Pill


Reply via email to