[python-win32] (again) get Window Title encoding

Mark Hammond mhammond at skippinet.com.au
Tue Mar 1 23:34:11 CET 2011


On 1/03/2011 10:38 PM, Creative iNFiNiTY wrote:
> Hello,
> i wan't to decode the title to utf-8
> 'mbcs' encoding doesn't help me
> sometimes the browser surf on russian, japanese, chinese language
> and i couldn't decode if i don't know the encoding.....
> thanks for your help

You can't decode the title to utf8 - what you need to do is decode the 
title *from* whatever encoding it is in, then encode it to utf8.  So 
something like window_title.decode('mbcs').encode('utf-8') should work 
in most cases.

HTH,

Mark


More information about the python-win32 mailing list