phil_gg04@treefic.com wrote:[color=blue][color=green]
>>I have some unicode (utf8) text file. I _tried_ to write a simple
>>program that read one of them and write it to the standard output
>> but... of course it doesn't work[/color]
>
> What character set do you want to use when writing to standard output? [..]
> If you want it to write using a character set other than the UTF-8 that
> it read in, you need to do some conversion. You have to do this
> explicitly. It will not happen automatically.[/color]
Thanks! I think I perfectly understood the problem.
My program was only an exercise, but the goal was learn how to "set" the
library (?) to read unicode (or eventually another encoding), manipulate
it using the string functionality of the standard library and then
write it back in a particular encoding on a file or to the standard output.
[color=blue]
> Assuming that your program is going to actually do
> something with the text, rather than just reading
> it in and then writing it out again, you need to
> decide what character set you want to use internally.[/color]
It's really necessary that I specify the internal encoding? At my level
(scholastic level) I have no performance problem so if does exists a
default encoding this is ok for me.
So I would like specify the input file encoding and the ouput file
encoding, than use my program, for example:
string s;
while (infile >> s) {
if (s=="hello")
{;} //delete "hello" from input
else
{cout << s;}
}
I don't want, if it's possible, to specify wstring, wcut and so on because
1 I don't want to change the program the day I will need a diffent encoding
2 The program written without wstring, wcut etc. is more natural and
general and don't touch the implementation level
[Old Wolf write][color=blue]
> I'm assuming you want to output UTF-8 on stdout (Standard
> C++ offers no facilities for converting UTF-8 to a stream
> of wide characters). Can you clarify your intention?[/color]
I hope now it's more clear.
Thanks to all for the help. K.