#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Posts
    8
    Rep Power
    0

    newbie - UNICODE and ASCII


    Hello, I am a new programer who recently switched frow using WIndows XP/DOS to RedHAt Linux 9.0. As a result most of the programs I wrote no loger work properly in linux. All of them are console applications and I believe the proble is that my linux console outputs in UNICODE rather then ASCII like I am used to. I use several special symbols in my programs (EG a heart). Previously in DOS all I would have to do to get a heart is:

    cout << char(4) << endl;

    at least I think 4 is right.
    But now when I recompile and try my programs I get '?' instead of these special symbols.

    Is there an easy way to fix this?
    Please remember I am still very much a newbie and need detailed explinations if possible.

    Thank you very much!
  2. #2
  3. jasondoucette.com
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Location
    Canada
    Posts
    378
    Rep Power
    12
    That heart character was a symbol of the font DOS used for character #4. ASCII is defined from 0..127, but anything under 32 is not supposed to be viewable, as far as I know. For example, you could 'print' #10 and #13 to the screen in DOS, if you really wanted (they each have their own symbol, like the heart for #4), but they actually mean CR and LF in ASCII.
  4. #3
  5. No Profile Picture
    .
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2002
    Posts
    296
    Rep Power
    13
    here's a couple of unicode hearts and their codes which you could try using:

    0x2764 - HEAVY BLACK HEART (or in utf8 - 0xE29DA4)

    0x2665 - BLACK HEART SUIT (utf8 - 0xE299A5)

    the second one is probably the more standard one as it also has an xhtml entity &hearts;
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Posts
    8
    Rep Power
    0

    um.......


    Yes, but *how* do you use unicode? If possible could someone provide an example.
    Thanks

    jmja89
  8. #5
  9. No Profile Picture
    .
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2002
    Posts
    296
    Rep Power
    13
    well looking at your bit of code and you saying you think your output occurs in unicode then i'd have a guess at this:

    cout << int(0x2665) << endl;
  10. #6
  11. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Posts
    8
    Rep Power
    0

    Not working


    Here's a sample code......

    PHP Code:
    #include <iostream>
    using namespace std;

    int main()
    {
        
    cout << int(0xE299A5) << endl;
        
    cout << int(0x2665) << endl;
        return 
    0;

    Yet my output is not a heart it is instead

    14850469
    9829

    and the charcter encoding in my terminal is UTF-8 of this I am sure. Thank you

    jmja89

IMN logo majestic logo threadwatch logo seochat tools logo