Filename encoding on XP

Discussion in 'Python' started by kent sin, Jan 3, 2007.

  1. kent sin

    kent sin Guest

    What encoding does the NTFS store the filename?

    I got some downloaded files, some with Chinese filename, I can not
    backup them to CD because the name is not accepted.

    I use walk, then print the filename, there are some ? in it, but some
    Chinese characters were display with no problem. I suspect the
    encoding of the filename is not unicode. How do I find out more about
    this?

    --
    Sin Hang Kin.
    kent sin, Jan 3, 2007
    #1
    1. Advertising

  2. kent sin schrieb:
    > What encoding does the NTFS store the filename?


    In UTF-16LE. However, on-disk storage is mostly irrelevant, what
    matters is what encoding is used on the OS API.

    Windows has two forms of file API: Wide (Unicode) and ANSI
    (byte-oriented). On NT, the Wide API is "native"; the ANSI API
    converts strings forth and back (introducing ? if the conversion
    fails).

    > I use walk, then print the filename, there are some ? in it, but some
    > Chinese characters were display with no problem. I suspect the
    > encoding of the filename is not unicode.


    You need to pass a Unicode string into walk as the directory; then
    recursively all results should also be Unicode strings.

    Regards,
    Martin
    =?UTF-8?B?Ik1hcnRpbiB2LiBMw7Z3aXMi?=, Jan 3, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?Sm9l?=

    Extract filename from a filename typed by user

    =?Utf-8?B?Sm9l?=, Aug 23, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    1,005
    Travis Murray
    Aug 24, 2004
  2. Replies:
    1
    Views:
    1,437
    Roland de Ruiter
    Jun 15, 2006
  3. Peter Otten
    Replies:
    0
    Views:
    409
    Peter Otten
    Nov 30, 2010
  4. Peter Otten
    Replies:
    10
    Views:
    857
    Nobody
    Dec 2, 2010
  5. Dan Stromberg
    Replies:
    0
    Views:
    909
    Dan Stromberg
    Dec 6, 2010
Loading...

Share This Page