AW: UTF-8 conversion
Jörg Pommnitz <[email protected]>
| Newsgroups | gmane.comp.mobile.kannel.devel |
|---|---|
| Message-ID | <4D93AAF95CB5A64E8F622EC796ECF5AC3FBE80@EXIL> |
Well, thats easy: your string is already URL encoded and those contains only ASCII characters. ASCII characters are a subset of UTF-8, so no conversation is required. To get what you want, you first have to URL decode the string and then apply the UTF-8 -> ISO-8859-1 conversion. Regards Joerg -----Ursprüngliche Nachricht----- Von: CHARBONNIER Christophe [mailto:[email protected]] Gesendet: Mittwoch, 21. Mai 2003 08:01 An: [email protected] Betreff: UTF-8 conversion Hi list, I'm trying to recode strings from UTF-8 to ISO-8859-1 charset, with this little piece of code: { Octstr *body = octstr_create("foo=100%25+des+%E9l%E9ments+%3D+%22%E7%22"); Octstr *body_final = NULL; debug("test", 0, "body: %s", octstr_get_cstr(body)); debug("test", 0, "octstr_recode rc = %d", octstr_recode(octstr_imm("iso-8859-1"), octstr_imm("utf-8"), body)); debug("test", 0, "body: %s", octstr_get_cstr(body)); debug("test", 0, "charset_from_utf8 rc = %d", charset_from_utf8(body, &body_final, octstr_imm("iso-8859-1"))); debug("test", 0, "body_final: %s", octstr_get_cstr(body_final)); debug("test", 0, "charset_convert rc = %d", charset_convert(body, "utf-8", "iso-8859-1")); debug("test", 0, "body: %s", octstr_get_cstr(body)); } But that doesn't look right. The return-codes of octstr_recode, charset_from_utf8 and charset_convert are 0 (means everything is right), but the string is not modified at all... Does anyboby can tell me what's wrong in my code ??? Thanxs in advance... Christophe