According to python Unicode-HOWTO, the default encoding will not be ASCII if I set LAND environment variable.
I have python2.7 on Mountain Lion, the $LANG environment variable is "en_US.UTF-8". Running "sys.getfilesystemencoding()" returns "utf-8", but running "sys.getdefaultencoding()" returns "ascii".
When I run the following:
struct.pack('12s',u'filename\u4500abc')
it failed with:
TypeError: Struct() argument 1 must be string, not unicode
Explicitly change to
struct.pack('12s',u'filename\u4500abc'.encode('utf-8'))
worked.
Question is what is the difference between "sys.getdefaultencoding" and "sys.getfilesystemencoding"? It seems the first is related with "struct.pack", and what is the second for? And how to make 'utf-8' as default encoding when doing "struct.pack"?