Created
December 19, 2015 14:04
-
-
Save mxey/56692d2f2db239a5c229 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
root@ubuntu-512mb-fra1-01:~# touch $(printf '\xff\xff\xffäöü') | |
root@ubuntu-512mb-fra1-01:~# ls | |
???äöü | |
>>> os.listdir(b".")[1] | |
b'\xff\xff\xff\xc3\xa4\xc3\xb6\xc3\xbc' | |
>>> os.listdir(".")[1] | |
'\udcff\udcff\udcffäöü' | |
>>> print(os.listdir(".")[1]) | |
Traceback (most recent call last): | |
File "<stdin>", line 1, in <module> | |
UnicodeEncodeError: 'utf-8' codec can't encode character '\udcff' in position 0: surrogates not allowed | |
[1] pry(main)> Dir.glob("*")[0] | |
=> "\xFF\xFF\xFFäöü" | |
[2] pry(main)> puts Dir.glob("*")[0] | |
???äöü | |
=> nil | |
[3] pry(main)> Dir.glob("*")[0].valid_encoding? | |
=> false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment