Read in UTF-8 file

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • 99miles

    Read in UTF-8 file

    Hello-
    I am having trouble figuring out how to read in a UTF-8 file. Could
    somebody please give me a simple example? I am using VS 6.0 writing
    for windows only. The file is a zstring.dct file.
    Thanks a lot-
    Mac
  • P.J. Plauger

    #2
    Re: Read in UTF-8 file

    "99miles" <pub@magusdesig ns.com> wrote in message
    news:f951419a.0 311011004.4654d 4ee@posting.goo gle.com...
    [color=blue]
    > I am having trouble figuring out how to read in a UTF-8 file. Could
    > somebody please give me a simple example? I am using VS 6.0 writing
    > for windows only. The file is a zstring.dct file.[/color]

    You need a codecvt facet that does the conversion for you. VC++ V6.0
    by default does a one-to-one conversion, which is not adequate for
    your needs. See our CoreX library, at our web site.

    P.J. Plauger
    Dinkumware, Ltd.



    Comment

    • Phlip

      #3
      Re: Read in UTF-8 file

      P.J. Plauger wrote:
      [color=blue]
      > 99miles wrote:
      >[color=green]
      > > I am having trouble figuring out how to read in a UTF-8 file. Could
      > > somebody please give me a simple example? I am using VS 6.0 writing
      > > for windows only. The file is a zstring.dct file.[/color]
      >
      > You need a codecvt facet that does the conversion for you. VC++ V6.0
      > by default does a one-to-one conversion, which is not adequate for
      > your needs. See our CoreX library, at our web site.[/color]

      Conversion from UTF-8 to what?

      --
      Phlip


      Comment

      • Phlip

        #4
        Re: Read in UTF-8 file

        99miles wrote:
        [color=blue]
        > I am having trouble figuring out how to read in a UTF-8 file. Could
        > somebody please give me a simple example? I am using VS 6.0 writing
        > for windows only. The file is a zstring.dct file.[/color]

        One reads UTF-8 via any 8-bit stream system, which on VC++ is a simple
        std::string, std::iostream, etc.

        However, strlen() will return the number of bytes, not the number of
        characters. In general the string manipulation functions will not be aware
        of the difference between characters and bytes.

        If you then try to display the string, that's a topic for a Win32 UI
        newsgroup.

        Tell them where you are getting stuck, because UTF-8 designs to be
        compatible with most platforms' strings.

        --
        Phlip


        Comment

        • P.J. Plauger

          #5
          Re: Read in UTF-8 file

          "Phlip" <phlip_cpp@yaho o.com> wrote in message
          news:2QTob.1840 1$DS3.5135@news svr32.news.prod igy.com...
          [color=blue]
          > P.J. Plauger wrote:
          >[color=green]
          > > 99miles wrote:
          > >[color=darkred]
          > > > I am having trouble figuring out how to read in a UTF-8 file. Could
          > > > somebody please give me a simple example? I am using VS 6.0 writing
          > > > for windows only. The file is a zstring.dct file.[/color]
          > >
          > > You need a codecvt facet that does the conversion for you. VC++ V6.0
          > > by default does a one-to-one conversion, which is not adequate for
          > > your needs. See our CoreX library, at our web site.[/color]
          >
          > Conversion from UTF-8 to what?[/color]

          UCS-2 or UCS-4. From there you can go to a gazillion other codes. See
          the documentation for CoreX at our web site.

          P.J. Plauger
          Dinkumware, Ltd.



          Comment

          Working...