UNICODE

Discussion in 'C++' started by Anarki, Jul 7, 2008.

  1. Anarki

    Anarki Guest

    I would like to print a string in unicode. I compiled using gcc 3.4.4
    in Cygwin(windows Xp). I used the following code. Gcc compiles it and
    links but not giving the expected output, g++ don't even compile it,
    it says wprintf is undeclared. I would also like to know why gcc
    compiles it and g++ dosen't. someone please help me print a unicode
    string using gcc or g++ in cygwin(windows xp)


    #include <wchar.h>
    int main()
    {
    wchar_t mal[] = L"ദീപàµâ€Œà´šà´¨àµà´¦àµâ€Œ പി";
    wprintf(mal);
    return 0;
    }
    Anarki, Jul 7, 2008
    #1
    1. Advertising

  2. Anarki a écrit :
    > I would like to print a string in unicode. I compiled using gcc 3.4.4
    > in Cygwin(windows Xp). I used the following code. Gcc compiles it and
    > links but not giving the expected output, g++ don't even compile it,
    > it says wprintf is undeclared.


    Use <cwchar> instead.

    > I would also like to know why gcc
    > compiles it and g++ dosen't.


    Without, the error message we can only guess (perhaps a conflict -
    mbstate_t ?).

    > someone please help me print a unicode
    > string using gcc or g++ in cygwin(windows xp)


    I assume your console is properly configured.

    #include <cwchar>
    #include <clocale> //for setlocale
    #include <cstdlib> //for SUCCESS

    int main()
    {
    wchar_t mal[] = L"ദീപàµâ€Œà´šà´¨àµà´¦àµâ€Œ പി";

    std::setlocale( LC_ALL, "XXX" );//your language: Indian ?

    std::wprintf(mal);
    return EXIT_SUCCESS;
    }
    Michael DOUBEZ, Jul 7, 2008
    #2
    1. Advertising

  3. Anarki

    Anarki Guest

    On Jul 7, 12:50 pm, Michael DOUBEZ <> wrote:
    > Anarki a écrit :
    >
    > > I would like to print a string in unicode. I compiled using gcc 3.4.4
    > > in Cygwin(windows Xp). I used the following code. Gcc compiles it and
    > > links but not giving the expected output, g++ don't even compile it,
    > > it says wprintf is undeclared.

    >
    > Use <cwchar> instead.
    >
    > > I would also like to know why gcc
    > > compiles it and g++ dosen't.

    >
    > Without, the error message we can only guess (perhaps a conflict -
    > mbstate_t ?).
    >
    > > someone please help me print a unicode
    > > string using gcc or g++ in cygwin(windows xp)

    >
    > I assume your console is properly configured.
    >
    > #include <cwchar>
    > #include <clocale> //for setlocale
    > #include <cstdlib> //for SUCCESS
    >
    > int main()
    > {
    >         wchar_t mal[] = L"ദീപàµâ€Œà´šà´¨àµà´¦àµâ€Œ പി";
    >
    > std::setlocale( LC_ALL, "XXX" );//your language: Indian ?
    >
    >         std::wprintf(mal);
    >         return EXIT_SUCCESS;
    >
    > }
    >
    >


    excuse me what u mean by properly configured console? I think i
    haven't done any configuring can you please guide me am a novice in
    configuring this cygwin all these days i was in visual studio, hope u
    will help me and by the way the posted program didn't work :(. The
    language i used was malayalam, language of Kerala/India.
    Anarki, Jul 7, 2008
    #3
  4. Anarki a écrit :

    > excuse me what u mean by properly configured console? I think i
    > haven't done any configuring can you please guide me am a novice in
    > configuring this cygwin all these days i was in visual studio,


    I mean your console should be configured to display unicode.
    echo "$LC_ALL"

    Should tell you if you have the good locale.

    > hope u
    > will help me and by the way the posted program didn't work :(.


    I guess you will find tutorial for your language somewhere on the web.

    > The
    > language i used was malayalam, language of Kerala/India.


    #include <cwchar>
    #include <clocale> //for setlocale
    #include <cstdlib> //for SUCCESS

    int main()
    {
    wchar_t mal[] = L"ദീപàµâ€Œà´šà´¨àµà´¦àµâ€Œ പി";

    //loacale for malayalam is ml_IN
    //if you use the UTF8 flavor, ml_IN.UTF8
    std::setlocale( LC_ALL, "ml_IN" );

    std::wprintf(mal);

    return EXIT_SUCCESS;
    }

    --
    Michael
    Michael DOUBEZ, Jul 7, 2008
    #4
  5. Anarki

    James Kanze Guest

    On Jul 7, 10:52 am, Michael DOUBEZ <> wrote:
    > Anarki a écrit :


    > > excuse me what u mean by properly configured console? I
    > > think i haven't done any configuring can you please guide me
    > > am a novice in configuring this cygwin all these days i was
    > > in visual studio,


    > I mean your console should be configured to display unicode.
    > echo "$LC_ALL"


    > Should tell you if you have the good locale.


    Maybe. Something like "env | grep LC_" and perhaps echo "$LANG"
    might be useful as well. However...

    I'm not too sure how CygWin works here; with an xterm, what
    counts is the font the console is using, and I wouldn't be
    surprised if there aren't dependencies with regards to the font
    and/or code page of the window as well.

    --
    James Kanze (GABI Software) email:
    Conseils en informatique orientée objet/
    Beratung in objektorientierter Datenverarbeitung
    9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
    James Kanze, Jul 7, 2008
    #5
  6. James Kanze a écrit :
    > On Jul 7, 10:52 am, Michael DOUBEZ <> wrote:
    >> Anarki a écrit :

    >
    >>> excuse me what u mean by properly configured console? I
    >>> think i haven't done any configuring can you please guide me
    >>> am a novice in configuring this cygwin all these days i was
    >>> in visual studio,

    >
    >> I mean your console should be configured to display unicode.
    >> echo "$LC_ALL"

    >
    >> Should tell you if you have the good locale.

    >
    > Maybe. Something like "env | grep LC_" and perhaps echo "$LANG"
    > might be useful as well. However...


    Yes $LANG would be better.

    >
    > I'm not too sure how CygWin works here; with an xterm, what
    > counts is the font the console is using, and I wouldn't be
    > surprised if there aren't dependencies with regards to the font
    > and/or code page of the window as well.


    It seems cygwin doesn't support unicode. So any out put is likely to be
    garbage.

    There is an UTF-8 cygwin:
    http://www.okisoft.co.jp/esc/utf8-cygwin/

    The OP should ask in a relevant group.

    --
    Michael
    Michael DOUBEZ, Jul 7, 2008
    #6
    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. Robert Mark Bram
    Replies:
    0
    Views:
    3,902
    Robert Mark Bram
    Sep 28, 2003
  2. ygao

    unicode wrap unicode object?

    ygao, Apr 8, 2006, in forum: Python
    Replies:
    6
    Views:
    525
    =?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=
    Apr 8, 2006
  3. Gabriele *darkbard* Farina

    Unicode digit to unicode string

    Gabriele *darkbard* Farina, May 16, 2006, in forum: Python
    Replies:
    2
    Views:
    493
    Gabriele *darkbard* Farina
    May 16, 2006
  4. gabor
    Replies:
    13
    Views:
    531
    Leo Kislov
    Nov 18, 2006
  5. Jean-Paul Calderone
    Replies:
    23
    Views:
    652
    Leo Kislov
    Nov 21, 2006
Loading...

Share This Page