3

I'm so lost on this topic that I don't even know how to properly phrase my question.

I have a bunch of weird escape delimited codes within unicode in python. I want to make it human readable. I believe that it must be once again be in unicode format because there are characters unrepresentable in ascii. How can I do this? There are simply too many things online like encode, decode, str, codec, etc etc that i'm not sure what to do anymore.

Thank you.

u"\u202e\u062c\u0647\u0627\u0646\u202c - \u202dBBC     
\u202e\u0641\u0627\u0631\u0633\u06cc\u202c - 
\u202e\u0646\u0634\u0633\u062a '\u062f"
Lucas Ou-Yang
  • 5,505
  • 13
  • 43
  • 62

1 Answers1

4

I believe you've got your hands on some Persian!

>>> foo = u"\u202e\u062c\u0647\u0627\u0646\u202c - \u202dBBC  \u202e\u0641\u0627\u0631\u0633\u06cc\u202c - \u202e\u0646\u0634\u0633\u062a
>>> print foo        
جهان‬ - ‭BBC  ‮فارسی‬ - ‮نشست 'د       

Stackoverflow's codeblock feature doesn't seem to like a combination of left-/right-aligned text very well, so here's a screenshot aswell:

Persian unicode output

It seems to be something about BBC World Persian (Iran). Atleast that's what Google translate indicates. It is horribly hard to get the order right because of broken selection, but the language seems to fit.

timss
  • 9,982
  • 4
  • 34
  • 56
  • Thanks but I have one additional question. I need the converted unicode stored in memory because it has to be sent over to an html template. The print method converts it fine but is there a way I can convert the code then store it in some variable, where I can send it over? – Lucas Ou-Yang Apr 21 '13 at 18:34
  • @LucasOu-Yang I'm not sure how you would do that. But atleast it seems to be possible to store special characters in a string, or atleast some of them. http://bpaste.net/show/wauSKEUlBgdxEu5aFPBF/ – timss Apr 21 '13 at 19:00