Skip to main content
Stack Overflow
  1. About
  2. For Teams

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

Unicode utf-8/utf-16 encoding in Python

In python:

u'\u3053\n'

Is it utf-16?

I'm not really aware of all the unicode/encoding stuff, but this type of thing is coming up in my dataset, like if I have a=u'\u3053\n'.

print gives an exception and decoding gives an exception.

a.encode("utf-16") > '\xff\xfeS0\n\x00'
a.encode("utf-8") > '\xe3\x81\x93\n'
print a.encode("utf-8") > πüô
print a.encode("utf-16") > しかくS0

What's going on here?

Answer*

Draft saved
Draft discarded
Cancel
1
  • 1
    thanks yes, powershell , even powershell ISE doesn't seem "compatable" (for lack of a better understanding) with unicode in python. stackoverflow.com/questions/2105022/… Commented Feb 5, 2010 at 17:21

lang-py

AltStyle によって変換されたページ (->オリジナル) /