[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: UTF-8 application
Jeu George writes:
>
> I would like to know if the input we give in can be of the type
> char * string= " hello"
> this is how u give input to a normal ascii string
> similarly how do u do it in when u want ot input a Utf-8 string
> keeping in mind that the utf-8 is a multibyte string whereas in C u have
> 1 byte for 1 string
If your program shall run only in the same locale as the one in which
you compile it -- i.e. basically if you write it only for yourself --
then you can write
const char * string = "UTF-8 encoded string, use an UTF-8 enabled editor";
But if your program shall run in different locales, possibly with
different character sets, you should use GNU gettext and write
const char * string = gettext ("an ASCII string serving as key");
> also u could say
> char a = 102 ;
> so a C program will print the charater corresponding to the ascii value
> when u print the variable a
Here you need to use 'wchar_t' instead of 'char'. And where you use
the printf directive %c to print a 'char', you use the directive %lc
to print a 'wchar_t'.
Bruno
-
Linux-UTF8: i18n of Linux on all levels
Archive: http://mail.nl.linux.org/lists/