Python, unicode, Windows32 and NTFS...
Hi, in my job I have a lot of differnt language to deal with, now including japan. And we have all these languages on our server (Windows 2000)... So NTFS uses UNICODE (I think it's 'utf-16'). Python -- at least since version 1.6 -- is supposed to understand and handle UNICODE. But my experience is, it doesn't support UNICODE for NTFS file names. eg: PythonWin 2.2.1 (#34, Apr 15 2002, 09:51:39) [MSC 32 bit (Intel)] on win32. Portions Copyright 1994-2001 Mark Hammond ([EMAIL PROTECTED]) - see 'Help/About PythonWin' for further copyright information. abc = u'a:\u03b1\u03b2\u03b3.txt'; print abc a:???.txt open(abc,'w').write('test') Traceback (most recent call last): File interactive input, line 1, in ? IOError: [Errno 2] No such file or directory: 'a:a\xdf?.txt' Oops! Does this mean, I have to use VisualBasicScript to handle this Or are there any swiches or tools or libs to use UNICODE filesystems? Thanks in advance Regards/Mir freundlichen Grüßen Werner Merkl -- -- Werner Merkl Senior Engineer Software Pre-Installation FSC VP BP PRO PI Fujitsu Siemens Computers Buergermeister-Ulrich-Str. 100 86199 Augsburg Germany Telephone: +49(0)821 804-3548 Telefax:+49(0)821 804-3835 E-mail: mailto: [EMAIL PROTECTED] Internet: http://www.fujitsu-siemens.com ___ ActivePython mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs Other options: http://listserv.ActiveState.com/mailman/listinfo/ActivePython
Re: Python, unicode, Windows32 and NTFS...
[Merkl, Werner wrote] Hi, in my job I have a lot of differnt language to deal with, now including japan. And we have all these languages on our server (Windows 2000)... So NTFS uses UNICODE (I think it's 'utf-16'). Python -- at least since version 1.6 -- is supposed to understand and handle UNICODE. But my experience is, it doesn't support UNICODE for NTFS file names. eg: PythonWin 2.2.1 (#34, Apr 15 2002, 09:51:39) [MSC 32 bit (Intel)] on win32. Portions Copyright 1994-2001 Mark Hammond ([EMAIL PROTECTED]) - see 'Help/About PythonWin' for further copyright information. abc = u'a:\u03b1\u03b2\u03b3.txt'; print abc a:???.txt open(abc,'w').write('test') Traceback (most recent call last): File interactive input, line 1, in ? IOError: [Errno 2] No such file or directory: 'a:a\xdf?.txt' Oops! Does this mean, I have to use VisualBasicScript to handle this Or are there any swiches or tools or libs to use UNICODE filesystems? I am far from the most knowledgeable about Unicode, but as far as I understand it you are right, Python is currently somehwat limited in its handling of Unicode filenames on Windows. There is a proposal to fix this in Python: Python Enhancement Proposal (PEP) 277: http://www.python.org/peps/pep-0277.html Unicode file name support for Windows NT Currently, I believe, Martin von Loewis is working on a patch for this and intends to get it to be part of Python 2.3. As a workaround you _might_ be able to work with unicode filenames by using the lower-lever Win32 API file handling calls exposed via the PyWin32 extensions. import win32file win32file.CreateFile(...) win32file.ReadFile(...) win32file.WriteFile(...) etc. Cheers, Trent -- Trent Mick [EMAIL PROTECTED] ___ ActivePython mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs Other options: http://listserv.ActiveState.com/mailman/listinfo/ActivePython
Re: Python, unicode, Windows32 and NTFS...
From: Merkl, Werner [EMAIL PROTECTED] Hi, in my job I have a lot of differnt language to deal with, now including japan. And we have all these languages on our server (Windows 2000)... So NTFS uses UNICODE (I think it's 'utf-16'). Python -- at least since version 1.6 -- is supposed to understand and handle UNICODE. But my experience is, it doesn't support UNICODE for NTFS file names. eg: PythonWin 2.2.1 (#34, Apr 15 2002, 09:51:39) [MSC 32 bit (Intel)] on win32. Portions Copyright 1994-2001 Mark Hammond ([EMAIL PROTECTED]) - see 'Help/About PythonWin' for further copyright information. abc = u'a:\u03b1\u03b2\u03b3.txt'; print abc a:???.txt open(abc,'w').write('test') Traceback (most recent call last): File interactive input, line 1, in ? IOError: [Errno 2] No such file or directory: 'a:a\xdf?.txt' Oops! Does this mean, I have to use VisualBasicScript to handle this Or are there any swiches or tools or libs to use UNICODE filesystems? No, none of that is the problem. The problem is that your underlying operating system does not use Unicode. (I am assuming you are using standard Win2K). If you switch to NT/J you will find your problems vanish. Assuming this is not a possibility, then you should use JIS or S-JIS to encode your file names (which only uses UTF-7) rather than UniCode. Your Win2K file system will understand these names without problem. Unfortunately, you have (inadvertently?) copyrighted your code, so I can not pick it apart to show you how to do this. Thanks in advance Regards/Mir freundlichen Grüßen Werner Merkl -- -- Werner Merkl Senior Engineer Software Pre-Installation FSC VP BP PRO PI Fujitsu Siemens Computers Buergermeister-Ulrich-Str. 100 86199 Augsburg Germany Telephone: +49(0)821 804-3548 Telefax: +49(0)821 804-3835 E-mail:mailto: [EMAIL PROTECTED] Internet: http://www.fujitsu-siemens.com ___ ActivePython mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs Other options: http://listserv.ActiveState.com/mailman/listinfo/ActivePython Exu [EMAIL PROTECTED] _ Join the worlds largest e-mail service with MSN Hotmail. http://www.hotmail.com ___ ActivePython mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs Other options: http://listserv.ActiveState.com/mailman/listinfo/ActivePython