Does somebody know how to print out wild character with unicode value greater than 255

Discussion in 'C++' started by jackie, Jan 5, 2005.

  1. jackie

    jackie Guest

    Here is my prolem: i try to output wstring with unicode value greater
    than 255(for each wchar_t) to a file such as test.tmp. Here is my code:

    wofstream outdata("test.tmp");
    wstring s;
    long l1=256;
    long l2=250;
    wchar_t c1=(wchar_t)l1;
    wchar_t c2=(wchar_t)l2;
    s+=l1;
    s+=l2;
    outdata<<s<<endl;
    outdata.close();

    However, there is nothing showes in the output file. But if i assign
    any positive value less than 256 to l1 such as: long l1=255, it works
    fine.
    could someone please tell me what is wrong with my code and the
    solution for it?
    thanks!
    jackie, Jan 5, 2005
    #1
    1. Advertising

  2. jackie

    Ron Natalie Guest

    Re: Does somebody know how to print out wild character with unicodevalue greater than 255

    jackie wrote:
    > Here is my prolem: i try to output wstring with unicode value greater
    > than 255(for each wchar_t) to a file such as test.tmp. Here is my code:
    >
    > wofstream outdata("test.tmp");
    > wstring s;
    > long l1=256;
    > long l2=250;
    > wchar_t c1=(wchar_t)l1;
    > wchar_t c2=(wchar_t)l2;
    > s+=l1;
    > s+=l2;

    Don't you want c1 and c2 here?

    > outdata<<s<<endl;
    > outdata.close();
    >


    Did you examine the output file with something that can inspect the
    characters? Maybe your font doesn't have anything in those positions.
    250 I don't even know what it should be. 256 is an A with a flat bar
    over it...not a common character.
    Ron Natalie, Jan 5, 2005
    #2
    1. Advertising

  3. "jackie" <> wrote in message
    news:...
    > Here is my prolem: i try to output wstring with unicode value greater
    > than 255(for each wchar_t) to a file such as test.tmp.


    Is it actually writing some characters to the file or is the file totally
    empty?

    If the former, you might try explicity opening the file as binary. If you
    open it as text, your characters may converted to unreadble
    ASCII.characters.
    E. R. Jacobson, Jan 7, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. BobRoyAce
    Replies:
    7
    Views:
    447
    Peter Blum
    Mar 3, 2005
  2. falcon
    Replies:
    10
    Views:
    18,513
    Roedy Green
    Feb 24, 2006
  3. RC
    Replies:
    6
    Views:
    1,634
    Mike Schilling
    Dec 14, 2006
  4. Paddy3118
    Replies:
    6
    Views:
    486
    TreeStages
    Dec 14, 2007
  5. Dwight Army of Champions
    Replies:
    4
    Views:
    2,681
    John H.
    Mar 17, 2010
Loading...

Share This Page