1

I'm new to python and I'm getting this error:

SyntaxError: Non-ASCII character '\xff' in file 'hiragana.py' on line 1, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

This is my code:

# -*- coding: utf-8 -*-
hiragana_map = {"A":u"あ","I":u"い","U":u"う","E":u"え","O":u"お"}

I tried it without the u's aswell. It doesn't make a difference. I'm using the Pycharm communitiy edition. In the encoding settings it says the file is encoded with UTF-16LE.

I'd appreciate any hints.

0

1 Answer 1

3

Python doesn't support source files encoded with with a fixed-width multi-byte codec such as UTF-16 or UTF-32.

Your file is encoded as UTF-16 Little Endian, which means the file starts with a Byte Order Mark; the first two bytes in the file are (hex) FF and FE. Python trips over the first byte.

Re-save the file as UTF-8 instead. See the PyCharm documentation, there is a section on changing the encoding.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for figuring this one out for me. Everything works fine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.