When I try to open a file containing Japanese using the Python
ʻopen ()` function in a Windous environment, the following error occurs.
UnicodeDecodeError: 'cp932' codec can't decode byte 0xef in position 60: illegal multibyte sequence
In the article here that I referred to, I taught you how to avoid the error by adding the encoding to the program.
However, it's hard to add encoding everywhere you use the Python
's ʻopen () function. It's painful to add encoding everywhere you use the ʻopen ()
function every time you install a package.
So, I investigated whether ʻUTF-8 encoding can be specified collectively in the
ʻopen ()function of
Python. As a result, it was found that it can be supported from the following versions of
Windows 10`, so the procedure is described.
We have confirmed that it works with the following OS versions.
Version: If it is 1709
or earlier, the target function is not implemented, so the following procedure cannot be performed.
Version: The version between 1709
and 1809
has not been verified.
Open the control panel and press the Region
link.
Press the Change System Localization
button on the Administration tab.
Check Use Unicode UTF-8 with worldwide language support
and press the ʻOK` button.
You will be asked to restart the system, so restart it.
I was able to check files containing Japanese using the package cfn-lint
in a Windows 10 environment.
$ cfn-lint test.yaml
E0000 did not find expected key
test.yaml:2:3
Although it is a feature of worldwide language support, it is a beta feature as shown in the screen capture, so using it may affect other features. At the time of writing this article, we have not verified all areas of influence. Those who use it are at their own risk.
Recommended Posts