Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Writing unicode characters to text file

Reply
Thread Tools

Writing unicode characters to text file

 
 
Lex Syntax
Guest
Posts: n/a
 
      06-21-2011
Hi,

I wanted to write a unicode character, e.g \u1200, to a text file.
Tried this but doesn't work:

int main(int argc, char* argv[])
{
std:fstream out("d:\\test.txt");
out << "\u1200";
out.close();
return 0;
}

Any ideas?
 
Reply With Quote
 
 
 
 
Juha Nieminen
Guest
Posts: n/a
 
      06-21-2011
Lex Syntax <> wrote:
> I wanted to write a unicode character, e.g \u1200, to a text file.
> Tried this but doesn't work:


What do you mean "it doesn't work"? What is it exactly that you want to
do. "Write a unicode character to a file" is not enough description to
know what is it that you want.

Unicode defines numerical values for characters. It doesn't define how
those values are stored. There are ancillary standards that define how
those values should be stored. Several ones. Most typical examples include
the UTF-8 and the UTF-16 formats. (In theory you could also store them
raw, which I suppose would be something akin to UTF-32, but even then
you have the problem of specifying endianess.)

If you want to store the unicode character eg. in UTF-8 format, you
have to convert it. There's (currently) no functionality in standard C++
to do this conversion, but you can use a third-party library such as
http://utfcpp.sourceforge.net/
 
Reply With Quote
 
 
 
 
Lex Syntax
Guest
Posts: n/a
 
      06-21-2011
On Jun 21, 2:31*pm, Juha Nieminen <nos...@thanks.invalid> wrote:
> Lex Syntax <lex.analy...@gmail.com> wrote:
> > I wanted to write a unicode character, e.g \u1200, to a text file.
> > Tried this but doesn't work:

>
> * What do you mean "it doesn't work"? What is it exactly that you want to
> do. "Write a unicode character to a file" is not enough description to
> know what is it that you want.
>
> * Unicode defines numerical values for characters. It doesn't define how
> those values are stored. There are ancillary standards that define how
> those values should be stored. Several ones. Most typical examples include
> the UTF-8 and the UTF-16 formats. (In theory you could also store them
> raw, which I suppose would be something akin to UTF-32, but even then
> you have the problem of specifying endianess.)
>
> * If you want to store the unicode character eg. in UTF-8 format, you
> have to convert it. There's (currently) no functionality in standard C++
> to do this conversion, but you can use a third-party library such ashttp://utfcpp.sourceforge.net/


Thanks for the explanation and the url.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Python unicode utf-8 characters and MySQL unicode utf-8 characters Grzegorz Śliwiński Python 2 01-19-2011 07:31 AM
Re: convert unicode characters to visibly similar ascii characters Laszlo Nagy Python 6 07-02-2008 04:42 PM
Re: convert unicode characters to visibly similar ascii characters M.-A. Lemburg Python 0 07-02-2008 08:39 AM
Re: convert unicode characters to visibly similar ascii characters Terry Reedy Python 0 07-01-2008 07:46 PM
Interrogating string for number of characters, response.writing identical number of characters on new line Ken Fine ASP General 2 02-05-2004 03:40 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57