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.
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.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
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.
It is too clear and so it is hard to see.
A dunce once searched for fire with a lighted lantern.
Had he known what fire was,
He could have cooked his rice much sooner.
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.
Last edited by Cat; 09-04-2006 at 02:45 PM.
You ever try a pink golf ball, Wally? Why, the wind shear on a pink ball alone can take the head clean off a 90 pound midget at 300 yards.
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.
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
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?
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
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
Last edited by shibu; 09-07-2006 at 12:42 AM.
Odd . . . are you having the same problem? What language do you speak? Do you think that you're in a different locale?
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.