UTF encoding extended character set for HTTP

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

UTF encoding extended character set for HTTP

rjulianford
Hello....

I am looking for a method to represent a String in the proper way,
in order to use if for an HTTP Get request, when the String contains
characters from the extended list (specifically, accented characters).

Before I write my own, I am hoping to find something already in place.
For example....

'This message
must be translated'

turns into...

'This%20message%0D%0Amust%20be%20translated'

When it is going to be sent as part of the message body in an HTTP
Get request.  Spaces must be represented by %20, and 
line delimiters must be replaced by %0A.

In String, there is the #sstUrlEncode method I was hoping would
do the trick....but it does not handle extended characters correctly.

For example, the name 'ANDRÉA' gets turned into 'ANDR%C9A',
using %C9 to represent the accented upper case E.
But this does not work...apparently, I must use %C3%89 to represent
this character.  So the name SHOULD be 'ANDR%C3%89A'.

I found this table, which seems to have the right info...
http://www.i18nqa.com/debug/utf8-debug.html

Can anyone steer me in the right direction?

Thanks in advance for any help...

Regards,
Julian Ford

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: UTF encoding extended character set for HTTP

nadja.xiatian
Hi Julian,

How about doing something like this:

('ANDRÉA' convertToCodePage: 'UTF-8') sstUrlEncode

Regards
Nadja

Am Mittwoch, 13. Dezember 2017 01:53:08 UTC+1 schrieb [hidden email]:
Hello....

I am looking for a method to represent a String in the proper way,
in order to use if for an HTTP Get request, when the String contains
characters from the extended list (specifically, accented characters).

Before I write my own, I am hoping to find something already in place.
For example....

'This message
must be translated'

turns into...

'This%20message%0D%0Amust%20be%20translated'

When it is going to be sent as part of the message body in an HTTP
Get request.  Spaces must be represented by %20, and 
line delimiters must be replaced by %0A.

In String, there is the #sstUrlEncode method I was hoping would
do the trick....but it does not handle extended characters correctly.

For example, the name 'ANDRÉA' gets turned into 'ANDR%C9A',
using %C9 to represent the accented upper case E.
But this does not work...apparently, I must use %C3%89 to represent
this character.  So the name SHOULD be 'ANDR%C3%89A'.

I found this table, which seems to have the right info...
<a href="http://www.i18nqa.com/debug/utf8-debug.html" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.i18nqa.com%2Fdebug%2Futf8-debug.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEYc9c27qx2lzRLWxcgkfX8my7svg&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.i18nqa.com%2Fdebug%2Futf8-debug.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEYc9c27qx2lzRLWxcgkfX8my7svg&#39;;return true;">http://www.i18nqa.com/debug/utf8-debug.html

Can anyone steer me in the right direction?

Thanks in advance for any help...

Regards,
Julian Ford

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: UTF encoding extended character set for HTTP

rjulianford
Hello, Nadja.

That worked perfectly....thank you!

I did suspect I was going to feel dumb when I heard the answer.....

THANKS!

Julian

On Wednesday, December 13, 2017 at 2:30:20 AM UTC-5, [hidden email] wrote:
Hi Julian,

How about doing something like this:

('ANDRÉA' convertToCodePage: 'UTF-8') sstUrlEncode

Regards
Nadja

Am Mittwoch, 13. Dezember 2017 01:53:08 UTC+1 schrieb [hidden email]:
Hello....

I am looking for a method to represent a String in the proper way,
in order to use if for an HTTP Get request, when the String contains
characters from the extended list (specifically, accented characters).

Before I write my own, I am hoping to find something already in place.
For example....

'This message
must be translated'

turns into...

'This%20message%0D%0Amust%20be%20translated'

When it is going to be sent as part of the message body in an HTTP
Get request.  Spaces must be represented by %20, and 
line delimiters must be replaced by %0A.

In String, there is the #sstUrlEncode method I was hoping would
do the trick....but it does not handle extended characters correctly.

For example, the name 'ANDRÉA' gets turned into 'ANDR%C9A',
using %C9 to represent the accented upper case E.
But this does not work...apparently, I must use %C3%89 to represent
this character.  So the name SHOULD be 'ANDR%C3%89A'.

I found this table, which seems to have the right info...
<a href="http://www.i18nqa.com/debug/utf8-debug.html" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.i18nqa.com%2Fdebug%2Futf8-debug.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEYc9c27qx2lzRLWxcgkfX8my7svg&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.i18nqa.com%2Fdebug%2Futf8-debug.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEYc9c27qx2lzRLWxcgkfX8my7svg&#39;;return true;">http://www.i18nqa.com/debug/utf8-debug.html

Can anyone steer me in the right direction?

Thanks in advance for any help...

Regards,
Julian Ford

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.