4 ms·
Windows is the platform where I see most of my Unicode problems. Here's an example of one of them: hello.py: print("こ") Ubuntu: $ python3 --version
by slavik81 8y ago
Windows is the platform where I see most of my Unicode problems. Here's an example of one of them:
hello.py:
print("こ")
Ubuntu:
$ python3 --version
Python 3.5.2
$ python3 hello.py
こ
$ python3 hello.py > out.txt
$ cat out.txt
こ
Windows:
C:\Users\u\tmp>python --version
Python 3.7.1
C:\Users\u\tmp>python hello.py
?
C:\Users\u\tmp>python hello.py > out.txt
Traceback (most recent call last):
File "hello.py", line 1, in <module>
print("?")
File "C:\Users\u\AppData\Local\Programs\Python\Python37-32\lib\encodings\
cp1252.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u3053' in position
0: character maps to <undefined>
- sametmax 8y agoThe cmd console is terrible. It has a limited set of unicode code point, and worse, an even more limited set of fonts support. The python unidecode pypi package is your best friend if you have to deal with it.
- josteink 8y ago> The cmd console is terrible. Agreed. And it's not really as much a native Windows app, as it is an emulator for the "good old" times of MS-DOS, which has received the necessary adjustments to keep chugging along, but little else. Given that you probably have what is the single weakest link unicode-wise you can find anywhere in the entirety of the Windows universe. It's really a completely obsoleted, abandoned mess. The fact that we had to wait until Windows 10 before you could actually resize the window freely should tell you at what level you should put your expectations. If you want to live your life in the command-line on Windows (for python or whatever else), do yourself a favour and get any other terminal. There's really quite a few to choose from. CMDer, ConEmu and MinTTY springs to mind.
- jacobush 8y agoWhat about this then? https://stackoverflow.com/a/47843552 https://stackoverflow.com/a/47843552 Claims unicode support is decent in Windows 8 and up.
- sametmax 8y agoYour post clearly state that not only you have to manually setup your console on each session for each machine to get anything remotly workable, but you need to limit yourself to a subset of unicode.
- sametmax 8y agoCmder is very decent.
- quietbritishjim 8y agoThis is because Python 3.5 and earlier used the old non-Unicode Windows API to access the console. This was fixed in Python 3.6: https://docs.python.org/3/whatsnew/3.6.html#whatsnew36-pep528 https://docs.python.org/3/whatsnew/3.6.html#whatsnew36-pep52...
- jai_ 8y agoBut he's using Python 3.7?