Fwd: ZnUrl issue with German characters

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Fwd: ZnUrl issue with German characters

Sven Van Caekenberghe-2
As this might be useful to others, forwarding:

> Begin forwarded message:
>
> Subject: Re: ZnUrl issue
> From: Sven Van Caekenberghe <[hidden email]>
> Date: 5 Mar 2015 09:55:46 CET
> To: Gerhard Obermann <[hidden email]>
>
> Hi Gerhard,
>
>> On 05 Mar 2015, at 08:36, Gerhard Obermann <[hidden email]> wrote:
>>
>> Hi sven,
>>
>> We are using Zinc (Gemstone) to access a restful interface.
>>
>> I didnt find a solution to send an url with german characters like "öäü".
>> Am i missing something?
>>
>> All such tests fails:
>>
>> ZnUrl fromString: '%F6lo'.
>> ZnUrl fromString: 'ölo'.
>> ZnUrl fromString: 'ölo' encodeAsUTF8 asString.
>>
>> json := (client := ZnClient new)
>> url: url;
>> accept: ZnMimeType applicationJson;
>> contentReader: [ :entity | | parserClass |
>> parserClass := Smalltalk at: #JSJsonParser.
>> parserClass parse: entity contents ];
>> ifFail: [:ex | ^ self error: 'HTTP request failed!' ];
>> get.
>>
>> Regards Gerhard
>
> This goes like this (in Pharo 4):
>
> 'ä' utf8Encoded hex => 'c3a4'
>
> 'http://de.wikipedia.de/wiki/Enzyklop%C3%A4die' asZnUrl.
>
> ZnUrl new
>  scheme: #http;
>  host: 'de.wikipedia.de';
>  addPathSegment: #wiki;
>  addPathSegment: 'Enzyklopädie';
>  yourself.
>
> Check the class comment: the print & parse forms are encoded, while the components & accessors are not.
>
> Does this work for you ?
>
> Sven

Gerhard solved his use case as follows:

ZnUrl new
  scheme: #http;
  host: 'dev.virtualearth.net';
  addPathSegments: #('REST' 'v1' 'Locations');
  queryAt: 'query' add: 'Jägerstraße';
  yourself.  

Sven