KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Here is a little program: import sys f = sys.argv[1] print type(f) print u"f=%s" % (f) Here is my running of the program: $ python x.py 'Recent/רשימת משתתפים.LNK' <type 'str'> Traceback (most recent call last): File "x.py", line 5, in <module> print u"f=%s" % (f) UnicodeDecodeError: 'ascii' codec can't decode byte 0xd7 in position 7: ordinal not in range(128) $ The problem is that sys.argv[1] is thinking that it's getting an ascii string, which it can't convert to Unicode. But I'm using a Mac with a full Unicode-aware Terminal, so x.py is actually getting a Unicode string. How do I tell Python that sys.argv[] is Unicode and not Ascii? Failing that, how do I convert ASCII (that has unicode inside it) into Unicode? The obvious conversions don't work.
Tags (comma-separated)
Save Edits
Cancel