hi frnds..
how to convert ascii character string to utf-8 format. does c library in linux give any function for this conversion?
Thxs in advance.
Shibu.
Printable View
hi frnds..
how to convert ascii character string to utf-8 format. does c library in linux give any function for this conversion?
Thxs in advance.
Shibu.
All ASCII encoded characters are UTF-8 encoded characters.
Not the C Standard librairy because UTF-8 is not part of the C librairy. C only provides a special type for dealing with 16 bit chars. Those wide characters do not actually have to be Unicode however.
IF your string is actually ASCII (that is, no values above 127) then it's already UTF-8 as Salem said.
If your string contains characters 128-255, it's not an ASCII string, and then you need to know which character set (Latin1, Shift-JIS, etc.) that the source string is in. I am not sure if there are any linux-specific functions for doing code page conversion, but it wouldn't be too hard to code a lookup table if your input character set was always the same.
I have a plain string passed to a gtk function. string is "acdrrt". Now as responded this should be in UTF-8 but gtk function is reporting to me it is not in UTF-8.
Could you post the code? Is there a 'L' following the string to indicate that the string is unicode? What happens if you pass the string constant directly? I bet it's how you store the string.
my code is given below
strcpy(a,"AAA");
glist=glist_append(glist,a);
but if I give
glist=glist_append(glist,"AAA")
it works fine.
Right, so how is a defined?
a is defined as
char a[15];
strcpy(a,"AAA");
glist=glist_append(glist,a);
here it reports invalid UTF-8 string passed to function
Odd . . . are you having the same problem? What language do you speak? Do you think that you're in a different locale?