stkutil: Use sms_dcs_decode in decode_text

This is a much more pedantic version that can be used to
retrieve the text character set.
This commit is contained in:
Guillaume Lucas 2010-11-25 16:15:04 +00:00 committed by Denis Kenzior
parent 3d1a4ec239
commit 9b690aad40
1 changed files with 8 additions and 4 deletions

View File

@ -77,9 +77,13 @@ struct gsm_sms_tpdu {
static char *decode_text(unsigned char dcs, int len, const unsigned char *data) static char *decode_text(unsigned char dcs, int len, const unsigned char *data)
{ {
char *utf8; char *utf8;
enum sms_charset charset;
switch (dcs) { if (!sms_dcs_decode(dcs, NULL, &charset, NULL, NULL))
case 0x00: return NULL;
switch (charset) {
case SMS_CHARSET_7BIT:
{ {
long written; long written;
unsigned long max_to_unpack = len * 8 / 7; unsigned long max_to_unpack = len * 8 / 7;
@ -94,10 +98,10 @@ static char *decode_text(unsigned char dcs, int len, const unsigned char *data)
g_free(unpacked); g_free(unpacked);
break; break;
} }
case 0x04: case SMS_CHARSET_8BIT:
utf8 = convert_gsm_to_utf8(data, len, NULL, NULL, 0); utf8 = convert_gsm_to_utf8(data, len, NULL, NULL, 0);
break; break;
case 0x08: case SMS_CHARSET_UCS2:
utf8 = g_convert((const gchar *) data, len, utf8 = g_convert((const gchar *) data, len,
"UTF-8//TRANSLIT", "UCS-2BE", "UTF-8//TRANSLIT", "UCS-2BE",
NULL, NULL, NULL); NULL, NULL, NULL);