Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How can find the text file encoded in other than ANSI format?

How can find the text file encoded in other than ANSI format?

Scheduled Pinned Locked Moved C / C++ / MFC
question
3 Posts 3 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Le rner
    wrote on last edited by
    #1

    Hi all, i m trying to read a Text file using CStdioFile,but this is fail and read some garbage values whan the file is encoded with other than ANSI format like Unicode,UTF-8 etc. please tell me before start reading how can i identify the file is not in ANSI format. i m waiting for ur valuable suggestions. thanks in advance.

    R L 2 Replies Last reply
    0
    • L Le rner

      Hi all, i m trying to read a Text file using CStdioFile,but this is fail and read some garbage values whan the file is encoded with other than ANSI format like Unicode,UTF-8 etc. please tell me before start reading how can i identify the file is not in ANSI format. i m waiting for ur valuable suggestions. thanks in advance.

      R Offline
      R Offline
      Rotted Frog
      wrote on last edited by
      #2

      It depends, For some file formats there is no way to tell them apart programatically (e.g. Chinese Big5 vs. Ansi). I imagine you are more interested in unicode specifically, though. For Unicode files there is normally a BOM (byte order mark) at the beginning of the file which tells you what the file format is. Look up Byte order marks on wikipedia for a really good explanation. Alternatively if you don't want to do this by hand, read this article[^] for a CStdiofile derived class that auto-detects the encoding.

      1 Reply Last reply
      0
      • L Le rner

        Hi all, i m trying to read a Text file using CStdioFile,but this is fail and read some garbage values whan the file is encoded with other than ANSI format like Unicode,UTF-8 etc. please tell me before start reading how can i identify the file is not in ANSI format. i m waiting for ur valuable suggestions. thanks in advance.

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        See here[^] for explanations of how to identify different encoded files.

        d@nish[^] has the answer.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups