| View previous topic :: View next topic |
| Author |
Message |
DFB_NZ Guest
|
Posted: Thu Jan 27, 2005 7:38 pm Post subject: stl wstring and string. |
|
|
Hi.
I have had problems compiling a simple program that uses wstring.
So....I wrote a small application that reads using char, fgetc etc in a
text file and writes it out to another text file. The japanese was
preserved in the outfile.
I am a c++ programmer from Microsoft and I use TCHAR etc so I am no stranger
to unicode on windows.
I am using eclipse, cgywin, windows 2k (Japanese Language support). gcc
3.3.3.
So why would I use wstring and wchar_t when string and char work with
Japanese anyway?
Thanks.
|
|
| Back to top |
|
 |
Victor Bazarov Guest
|
Posted: Thu Jan 27, 2005 7:45 pm Post subject: Re: stl wstring and string. |
|
|
DFB_NZ wrote:
| Quote: | I have had problems compiling a simple program that uses wstring.
|
This is covered in the FAQ 5.8.
| Quote: | So....I wrote a small application that reads using char, fgetc etc in a
text file and writes it out to another text file. The japanese was
preserved in the outfile.
I am a c++ programmer from Microsoft and I use TCHAR etc so I am no stranger
to unicode on windows.
I am using eclipse, cgywin, windows 2k (Japanese Language support). gcc
3.3.3.
So why would I use wstring and wchar_t when string and char work with
Japanese anyway?
|
I don't know. Why would you use something you don't seem to need?
V
|
|
| Back to top |
|
 |
DFB_NZ Guest
|
Posted: Fri Jan 28, 2005 7:02 pm Post subject: Re: stl wstring and string. |
|
|
Could you be more specific about "This is covered in the FAQ 5.8."
ie could you please paste a URL link or something.
I found that even in MSVC 6.0 if I use char and read/write a japanese
file the japanese is preserved. I am confused. I thought I had to use
TCHAR everywhere for non-ascii text. I compiled using MBCS and
therefore used char to read in japanese text then write it out to a
text file. the output file still had japanese in it.
Can someone offer anytype of explanation..?
|
|
| Back to top |
|
 |
Victor Bazarov Guest
|
Posted: Fri Jan 28, 2005 7:09 pm Post subject: Re: stl wstring and string. |
|
|
DFB_NZ wrote:
| Quote: | Could you be more specific about "This is covered in the FAQ 5.8."
ie could you please paste a URL link or something.
|
Definitely. Start here: http://www.slack.net/~shiva/welcome.txt
|
|
| Back to top |
|
 |
Jonathan Turkanis Guest
|
Posted: Fri Jan 28, 2005 7:35 pm Post subject: Re: stl wstring and string. |
|
|
DFB_NZ wrote:
| Quote: | Could you be more specific about "This is covered in the FAQ 5.8."
ie could you please paste a URL link or something.
I found that even in MSVC 6.0 if I use char and read/write a japanese
file the japanese is preserved.
|
If you open files in binary mode and use the "C" locale you can use narrow
streams for transfering data without regard to its textual content.
If you need to do more than transfer data between files, e.g., if you need to
perform regex subsitutions, you should imbue the file stream with an appropriate
local and use wide characters.
| Quote: | I am confused. I thought I had to use
TCHAR everywhere for non-ascii text. I compiled using MBCS and
therefore used char to read in japanese text then write it out to a
text file. the output file still had japanese in it.
Can someone offer anytype of explanation..?
|
Jonathan
|
|
| Back to top |
|
 |
Jerry Coffin Guest
|
Posted: Fri Jan 28, 2005 8:14 pm Post subject: Re: stl wstring and string. |
|
|
DFB_NZ wrote:
[ ... ]
| Quote: | So....I wrote a small application that reads using char, fgetc etc in
a
text file and writes it out to another text file. The japanese was
preserved in the outfile.
|
[ ... ]
| Quote: | So why would I use wstring and wchar_t when string and char work with
Japanese anyway?
|
It all depends on what you're doing with the text. Reading and writing
narrow characters will work fine as long as your program basically just
passes the text through without caring about how many of those narrow
characters go to compose on real Japanese character.
If, however, your program needs to deal with the characters as
characters and (for example) cares about the boundary between one
character and the next, then converting them to wide characters will
start to make a lot more sense. The Unicode encodings are mostly pretty
easy (UCS-4 is trivial, but even UTF-8 is still fairly simple) but
(just for one example) Shift-JIS is seriously ugly, to put it nicely --
if you have to deal with it, you'd strongly prefer to use some
pre-written code. Of course, UCS-4 is rare and Shift-JIS almost
unavoidable...
--
Later,
Jerry.
The univserse is a figment of its own imagination.
|
|
| Back to top |
|
 |
Larry Brasfield Guest
|
Posted: Sat Jan 29, 2005 12:22 pm Post subject: Re: stl wstring and string. |
|
|
"DFB_NZ" <dbrown (AT) statestreet (DOT) com> wrote
| Quote: | Could you be more specific about "This is covered in the FAQ 5.8."
ie could you please paste a URL link or something.
|
This was posted earlier in this very thread:
http://www.slack.net/~shiva/welcome.txt
Go there. It leads to the FAQ. If you are too lazy to
do that, I am not inclined to help and many other will
feel the same way.
| Quote: | I found that even in MSVC 6.0 if I use char and read/write a japanese
file the japanese is preserved. I am confused. I thought I had to use
TCHAR everywhere for non-ascii text. I compiled using MBCS and
therefore used char to read in japanese text then write it out to a
text file. the output file still had japanese in it.
Can someone offer anytype of explanation..?
|
--
--Larry Brasfield
email: [email]donotspam_larry_brasfield (AT) hotmail (DOT) com[/email]
Above views may belong only to me.
|
|
| Back to top |
|
 |
|