[Tutor] Re: Convert CJK text into HEX value string
Mon, 15 Jul 2002 07:47:02 -0400
On Monday, July 15, 2002, at 12:42 AM, Derrick 'dman' Hudson wrote:
> The general method is to use the unicode() constructor to create a
> unicode string object from whatever your input source is, and then use
> the .encode() method to encode that in which ever encoding is
> appropriate. Then use the quote() method in the urllib module to
> url encode it. So, for example, using latin1 and utf-8 :
Pardon me for jumping in on this thread, but I'm curious -- does the
string have to be converted to unicode because that's the encoding that
URL encodings must be taken from? Or is there some other reason it's
being converted to unicode first?
And, sorta off-topic... why does it need to be converted to "utf-8"...
that's something further than unicode?
I just thought of a neat "tool" script, one that would take a string as
input and return a URL encoding of that string... I'm sure it's been
written dozens of times before but it's probably easier to write than it
is to hunt down on the net.