3

Okay, I am not sure if I am phrasing this correctly but I am given url in the following form:

http://zh.wikipedia.org/wiki/%E5%A4%A9%E6%96%87%E5%AD%B8

but I would to convert it into Chinese characters like so:

http://zh.wikipedia.org/wiki/天文學

what is a good language to batch process that in? Are there existing functions to do the conversion or do I have to rely on string manipulation. It seems like to convert requires some sort of a call to a lookup table.

I know that they are the same thing but they are shown differently. I like it in readable characters not with %#.

boobami
  • 101
  • 2
  • 11
  • 1
    That "ASCII String" is the [(URL) Percent-encoding](http://en.wikipedia.org/wiki/Percent-encoding) of the Unicode text. (Only certain characters are allowed in URIs/URLs and these must be encoded before sending the "HTTP request" to the server.) –  Aug 29 '12 at 00:09
  • If the URL is opened in Safari, then [http://zh.wikipedia.org/wiki/天文學](http://zh.wikipedia.org/wiki/天文學) is shown in the URL location .. which is easy to copy'n'paste. Note that this is **not** UTF-8, but merely the pretty representation of a Unicode string: UTF-8 would be one possible encoding of the *byte* sequence of such Unicode characters. –  Aug 29 '12 at 00:11
  • pst, thank you for clarifying that for me. Appreciate it. – boobami Aug 29 '12 at 00:53
  • @JMax, thank you for pointing that out. But I wasn't sure why I someone had to point out that the question wasn't a programming one, when it is. That's all. I am new but that seems a bit impolite. Maybe I am just old school. Thanks. – boobami Aug 29 '12 at 07:41
  • @jih: first, I suggest you go to your profile page, go back to your previous questions and accept the more relevant answers. Second, you can ask another question but be sure to make yourself clearer. In your current question, you are asking for a `program`. Hence, this is not a programming question but a user question that you could try to ask on http://superuser.com (similar website as Stackoverflow). If it is still a programming question, please try to explain yourself better. The better the question, the better the answers. Good luck for finding your needs. – JMax Aug 29 '12 at 08:11

1 Answers1

3

In JavaScript

alert(decodeURI("http://zh.wikipedia.org/wiki/%E5%A4%A9%E6%96%87%E5%AD%B8"))​

See http://jsfiddle.net/rtoal/uv2Xy/

For other languages, search the web for "url decoding" (or uri decoding).

Ray Toal
  • 86,166
  • 18
  • 182
  • 232
  • Ray, thanks. This should give me some directions to look. – boobami Aug 29 '12 at 00:49
  • I also found that Python has a urllib with an unquote function. And if I type that into the Terminal it would decode properly as well. – boobami Aug 30 '12 at 05:00
  • >>> import urllib >>> urllib.unquote('%E5%A4%A9%E6%96%87%E5%AD%B8') '\xe5\xa4\xa9\xe6\x96\x87\xe5\xad\xb8' >>> print urllib.unquote('%E5%A4%A9%E6%96%87%E5%AD%B8') 天文學 – boobami Aug 30 '12 at 05:00