(encoding error) Python text file loading problem.

Asked 2 years ago, Updated 2 years ago, 22 views

The title is written like that, but I think I haven't found the right solution.

The original file is a text file containing old Hangul, but even if you save it with all Unicode storage options, such as Unicode, utf-16, and utf-8, it will not open in Python. (First of all, I have tried all the forms of pages that appear when I search for standard encoding on Google, such as utf-16 and utf-16-le on Python.)

The error message is UnicodeEncodeError: 'UCS-2' code can't code characters in position 28623-28623: Non-BMP character not supported in Tk'.

When I googled, there are people who wrote that using a program like Faicham opens, but this solution cannot be applied because I have to use only the default Python editor. What's the problem?

python

2022-09-21 16:57

1 Answers

First of all, the problem seems to be that it does not support 4-byte utf8 characters.

Is it done in Windows cmd? Try it on a shell that supports utf8 instead of cmd.

If you need to do it in cmd, do it in the cmd state, that is, on the prompt, as shown below.

chcp 65001

Then run the Python file


2022-09-21 16:57

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.