Trouble with the encoding of os.getcwd() in Korean Windows

Vincent Wehren vincent at visualtrans.de
Wed Feb 9 08:20:54 EST 2005


Erik Bethke wrote:
> Hello All,
> 
> I have found much help in the google archives but I am still stuck...
> 
> here is my code snippet:
> 	path = os.getcwd()
>         path = path.decode('UTF8')
> 
> Now the trouble is I am getting that darn UnicodeDecodeError, where it
> is tripping up on the Korean hangul for My Desktop.  Now I have tried
> utf8 and utf16 and neither of these works.


> 
> So is this my question?:  What encoding does windows use for Korean
> Windows?  

Try "mbcs". This is a built-in encoding avalaible only on Windows and 
that equals the system's default ANSI codepage. Using "mbcs", which is 
short for "multi-byte character set", the conversions to and from 
Unicode (decode/encode) are internally handled by the corresponding 
win32 api functions.

--
Vincent Wehren

I thought it might be and so I surfed around
> (http://foundationstone.com.au/HtmlSupport/OnlineHelp/Localisation/SupportedEncodings.html)
> and there appears to be an encoding called: windows-949 labeled to be
> Korean Windows, which of couse is *not* one of the encodings to be
> found in the encodings package... which would suck.
> 
> But then I thought about it some more, how could you make software to
> do things like read the current directory work on different language
> machines???  It would be madness to have a try statement for each and
> every encoding under the sun...
> 
> Why isn't there a get system encoding method?
> 
> Or am I on the entirely wrong track?
> 
> Thanks,
> -Erik
> 



More information about the Python-list mailing list