summaryrefslogtreecommitdiffstats
path: root/src/stkutil.c
diff options
context:
space:
mode:
authorGuillaume Lucas <guillaumex.lucas@intel.com>2010-11-25 16:15:04 +0000
committerDenis Kenzior <denkenz@gmail.com>2010-11-25 17:57:26 -0600
commit9b690aad40a3c39e9e46fc26beb0e3f43af6a997 (patch)
treec5b2f7dff5c4abae40d16feb2c777fe90022ee00 /src/stkutil.c
parent3d1a4ec2393e23cc7c3e54a92750b4d0c0f0bcf4 (diff)
downloadofono-9b690aad40a3c39e9e46fc26beb0e3f43af6a997.tar.bz2
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.
Diffstat (limited to 'src/stkutil.c')
-rw-r--r--src/stkutil.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/stkutil.c b/src/stkutil.c
index 377ceff0..78efbf0b 100644
--- a/src/stkutil.c
+++ b/src/stkutil.c
@@ -77,9 +77,13 @@ struct gsm_sms_tpdu {
static char *decode_text(unsigned char dcs, int len, const unsigned char *data)
{
char *utf8;
+ enum sms_charset charset;
- switch (dcs) {
- case 0x00:
+ if (!sms_dcs_decode(dcs, NULL, &charset, NULL, NULL))
+ return NULL;
+
+ switch (charset) {
+ case SMS_CHARSET_7BIT:
{
long written;
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);
break;
}
- case 0x04:
+ case SMS_CHARSET_8BIT:
utf8 = convert_gsm_to_utf8(data, len, NULL, NULL, 0);
break;
- case 0x08:
+ case SMS_CHARSET_UCS2:
utf8 = g_convert((const gchar *) data, len,
"UTF-8//TRANSLIT", "UCS-2BE",
NULL, NULL, NULL);