I'm having a bit of trouble with a file containing the "ș" character (that's \xC8\x99
in UTF-8 - LATIN SMALL LETTER S WITH COMMA BELOW).
I'm creating a ș.txt
file and trying to get it back with os.listdir()
. Unfortunately, os.listdir()
returns it back as s\xCC\xA6
("s" + COMBINING COMMA BELOW) and my test program (below) fails.
This happens on my OS X, but it works on a Linux machine. Any idea what exactly causes this behavior (both environments are configured with LANG=en_US.UTF8) ?
Here's the test program:
#coding: utf-8
import os
fname = "ș.txt"
with open(fname, "w") as f:
f.write("hi")
files = os.listdir(".")
print "fname: ", fname
print "files: ", files
if fname in files:
print "found"
else:
print "not found"