Click here to Skip to main content
15,914,444 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi my code is
C
#include<stdio.h>
#include<conio.h>
void main(void)
{
  char c=0x61;
  printf("%c",c);
  getch();
}

output
a


i have modified it to
C
#include<stdio.h>
#include<conio.h>
#include<unicode/uchar.h>
void main(void)
{
  UChar c=0x61;
  printf("%c",c);
  getch();
}


output
a


now if i change the UCHar c to 0x90f i want to display a hindi character
but vc displays some thing else

what is going wrong
please help
regards
harshada


Edit: select "ignore HTML in text"
Posted
Updated 22-Feb-10 22:53pm
v4

Writing international text to Windows console is a little more complicated than it should be. You'll need to use _O_U16TEXT[^] flag.
 
Share this answer
 
The UCHAR type is still only 8 bits wide, so the value 0x90f will be truncated. You should use the WCHAR type thus:
WCHAR wc=0x90f;
printf("%C", wc);
 
Share this answer
 
the problem is not solved by using wchar_t
it still displays the smae charcter
i want to use the ICU library
 
Share this answer
 
In addition to Richard's answer, you also have to use wprintf instead of printf. I suggest you read this article[^], it will help you a lot understanding the concepts and it will save you a LOT of time in the future.

[edit]from Richard: printf("%C", wc); will correctly print a WCHAR.[/edit]
 
Share this answer
 
v2
harshadaj wrote:
the problem is not solved by using wchar_t
it still displays the smae charcter
i want to use the ICU library


You need to have the correct font selected to get the right character displayed so a simple printf may not be enough. I have no idea what the ICU library is, but I expect it has some documentation with it.
 
Share this answer
 
how to set a correct font type .
ICU is IBMs unicode handling library
 
Share this answer
 
harshadaj wrote:
ICU is IBMs unicode handling library


Well I guess you need to consult its documentation. However there are many fonts available that you can use directly in Windows applications.
Take a look at CreateFont()[^] and its associated functions.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900