[merge][0.11] bugfix 56815: export unicode files to tar+zip

John Arbash Meinel john at arbash-meinel.com
Thu Sep 28 15:33:37 BST 2006


Alexander Belchenko wrote:
> Here is my proposed function for win32 to convert unicode filenames to
> OEM encoded ones to use in zip exporter.
> 
> John, what you think about?
> 
> -- 
> Alexander
> 
> 
> 

I think the function is okay. I really wish there was a way to determine
OEM encoding and do it ourselves, because then we could test it more
directly.

I'm leaning towards your idea of just not exporting unicode chars to a
zip file, and giving a direction for people to do it themselves.

John
=:->


> ------------------------------------------------------------------------
> 
> """Convert unicode filename to OEM character set to store in zip file"""
> 
> try:
>    import ctypes
>    has_ctypes = True
> except ImportError:
>     has_ctypes = False
> 
> 
> def unicode_to_oem(filename):
>     """Convert unicode filename to OEM filename
>     :param  filename:   filename to convert
>     :type   filename:   unicode
>     :return:            OEM-encoded filename
>     :rtype:             string
>     :raise:             UnicodeError
>     """
>     if has_ctypes:
>         buf = ctypes.create_string_buffer(256)
>         result = ctypes.windll.user32.CharToOemW(filename, buf)
>         if result:
>             return buf.value
>     raise UnicodeError("Can't convert %r to OEM" % filename)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 254 bytes
Desc: OpenPGP digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060928/f9cb4aa3/attachment.pgp 


More information about the bazaar mailing list