Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > UNICODE

Reply
Thread Tools

UNICODE

 
 
Anarki
Guest
Posts: n/a
 
      07-07-2008
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;
}
 
Reply With Quote
 
 
 
 
Michael DOUBEZ
Guest
Posts: n/a
 
      07-07-2008
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;
}
 
Reply With Quote
 
 
 
 
Anarki
Guest
Posts: n/a
 
      07-07-2008
On Jul 7, 12:50*pm, Michael DOUBEZ <(E-Mail Removed)> 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.
 
Reply With Quote
 
Michael DOUBEZ
Guest
Posts: n/a
 
      07-07-2008
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
 
Reply With Quote
 
James Kanze
Guest
Posts: n/a
 
      07-07-2008
On Jul 7, 10:52 am, Michael DOUBEZ <(E-Mail Removed)> 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:(E-Mail Removed)
Conseils en informatique oriente objet/
Beratung in objektorientierter Datenverarbeitung
9 place Smard, 78210 St.-Cyr-l'cole, France, +33 (0)1 30 23 00 34
 
Reply With Quote
 
Michael DOUBEZ
Guest
Posts: n/a
 
      07-07-2008
James Kanze a crit :
> On Jul 7, 10:52 am, Michael DOUBEZ <(E-Mail Removed)> 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
 
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
Re: os.lisdir, gets unicode, returns unicode... USUALLY?!?!? Jean-Paul Calderone Python 23 11-21-2006 10:25 AM
os.lisdir, gets unicode, returns unicode... USUALLY?!?!? gabor Python 13 11-18-2006 09:23 AM
Unicode digit to unicode string Gabriele *darkbard* Farina Python 2 05-16-2006 01:15 PM
unicode wrap unicode object? ygao Python 6 04-08-2006 09:54 AM
Unicode + jsp + mysql + tomcat = unicode still not displaying Robert Mark Bram Java 0 09-28-2003 05:37 AM



Advertisments