Read in UTF-8 file

9

99miles

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

Phlip

99miles said:
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.

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.
 
P

P.J. Plauger

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.

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.
http://www.dinkumware.com
 
P

Phlip

P.J. Plauger said:
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.

Conversion from UTF-8 to what?
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,146
Messages
2,570,831
Members
47,374
Latest member
anuragag27

Latest Threads

Top