diff options
author | Denis Kenzior <denkenz@gmail.com> | 2010-03-30 10:20:49 -0500 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2010-03-30 10:21:56 -0500 |
commit | 402c27f914ebad8d7ee36a16b9aa042e21b42310 (patch) | |
tree | df5d60682c89eff39100454a6b4018622c5032fb | |
parent | f8140bf66bd87e30fd6caf7014c983f5952c42f6 (diff) | |
download | ofono-402c27f914ebad8d7ee36a16b9aa042e21b42310.tar.bz2 |
Refactor: Break out the STK text decoding utility
This can be used for other data objects than text and default text
-rw-r--r-- | src/stkutil.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/stkutil.c b/src/stkutil.c index eb41a06b..710379fd 100644 --- a/src/stkutil.c +++ b/src/stkutil.c @@ -50,6 +50,41 @@ struct gsm_sms_tpdu { unsigned char tpdu[164]; }; +static char *decode_text(unsigned char dcs, int len, const unsigned char *data) +{ + char *utf8; + + switch (dcs) { + case 0x00: + { + long written; + unsigned long max_to_unpack = len * 8 / 7; + unsigned char *unpacked = unpack_7bit(data, len, 0, FALSE, + max_to_unpack, + &written, 0); + if (unpacked == NULL) + return FALSE; + + utf8 = convert_gsm_to_utf8(unpacked, written, + NULL, NULL, 0); + g_free(unpacked); + break; + } + case 0x04: + utf8 = convert_gsm_to_utf8(data, len, NULL, NULL, 0); + break; + case 0x08: + utf8 = g_convert((const gchar *) data, len, + "UTF-8//TRANSLIT", "UCS-2BE", + NULL, NULL, NULL); + break; + default: + utf8 = NULL; + } + + return utf8; +} + /* For data object only to indicate its existence */ static gboolean parse_dataobj_common_bool(struct comprehension_tlv_iter *iter, gboolean *out) |