Encoded file

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • pengz1@netzero.com

    Encoded file


    Hi!
    Could I ask you, how can I know a file is encoded as 'UTF-8', 'UTF-16' or something else? Thanks in advance.

    Zhi

    _______________ _______________ _______________ _______________ ____
    The best thing to hit the Internet in years - NetZero HiSpeed!
    Surf the Web up to FIVE TIMES FASTER!
    Only $14.95/ month -visit www.netzero.com to sign up today!

  • Michel Claveau/Hamster

    #2
    Re: Encoded file

    Hi !



    See in the module "codecs.py" :


    # UTF-8
    BOM_UTF8 = '\xef\xbb\xbf'

    # UTF-16, little endian
    BOM_LE = BOM_UTF16_LE = '\xff\xfe'

    # UTF-16, big endian
    BOM_BE = BOM_UTF16_BE = '\xfe\xff'

    # UTF-32, little endian
    BOM_UTF32_LE = '\xff\xfe\x00\x 00'

    # UTF-32, big endian
    BOM_UTF32_BE = '\x00\x00\xfe\x ff'



    --
    @-salutations
    --
    Michel Claveau
    site : http://mclaveau.com


    Comment

    • Paul Watson

      #3
      Re: Encoded file


      <pengz1@netzero .com> wrote in message
      news:mailman.10 4.1079555760.74 2.python-list@python.org ...[color=blue]
      >
      > Hi!
      > Could I ask you, how can I know a file is encoded as 'UTF-8', 'UTF-16' or[/color]
      something else? Thanks in advance.[color=blue]
      >
      > Zhi[/color]

      While there are BOM (Byte Order Mark) indicators specified by the Unicode
      standard, very few files actually have them.

      In general, this is still an old-fashioned protocol. You can ask the person
      or look at the code that created the file.


      Comment

      Working...