summaryrefslogtreecommitdiff
path: root/src/pdu_decode.c
diff options
context:
space:
mode:
authorBrandon Bayer <bbayer@multitech.com>2015-11-16 09:59:15 -0600
committerBrandon Bayer <bbayer@multitech.com>2015-11-17 09:27:36 -0600
commitd8be565fc564cbd6e3beaddb3fc77b311abf2359 (patch)
tree5c6e960dee414104cd1e0ba227ac674bfc9cf7f1 /src/pdu_decode.c
parentf3b916f22265f3f173987e28d8fdc2c8a3502519 (diff)
downloadsms-utils-d8be565fc564cbd6e3beaddb3fc77b311abf2359.tar.gz
sms-utils-d8be565fc564cbd6e3beaddb3fc77b311abf2359.tar.bz2
sms-utils-d8be565fc564cbd6e3beaddb3fc77b311abf2359.zip
feat: implement IRA->GSM character set encoding & decoding0.0.10
This adds support for certain characters like @ $ ~ ^
Diffstat (limited to 'src/pdu_decode.c')
-rw-r--r--src/pdu_decode.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/pdu_decode.c b/src/pdu_decode.c
index 140fd14..934aef5 100644
--- a/src/pdu_decode.c
+++ b/src/pdu_decode.c
@@ -309,6 +309,31 @@ int pdu_decode_user_data(const char *pdu_str, struct pdu_info *pdu, int *nr_octe
pdu->user_data[i] = '\0';
}
+ //Only for 7-bit character sets
+ if ((pdu->data_coding.general.alphabet == PDU_ALPHABET_DEFAULT) ||
+ (pdu->data_coding.general.alphabet == PDU_ALPHABET_CDMA_DEFAULT)) {
+ int read = 0;
+ int store = 0;
+
+ log_debug("Converting from GSM character set to IRA");
+ for (read = 0; read < pdu->user_data_len; read++) {
+ if (pdu->user_data[read] == 0x1B) {
+ //Character from the extended set using the escape char (27)
+ read++;
+ log_debug("GSM before: 0x1B%02X | IRA after: 0x%02X", pdu->user_data[read], strExtendedTable[pdu->user_data[read]]);
+ pdu->user_data[store] = strExtendedTable[pdu->user_data[read]];
+ }
+ else {
+ log_debug("GSM before: 0x%02X | IRA after: 0x%02X", pdu->user_data[read], strGSMTable[pdu->user_data[read]]);
+ pdu->user_data[store] = strGSMTable[pdu->user_data[read]];
+ }
+ store++;
+ }
+ //Update lengths
+ pdu->user_data_len -= read - store;
+ pdu_str -= (read - store) * HEX_BYTE_LEN;
+ }
+
return pdu_str - begin;
}