diff options
author | Anders Broman <anders.broman@ericsson.com> | 2008-01-08 05:18:36 +0000 |
---|---|---|
committer | Anders Broman <anders.broman@ericsson.com> | 2008-01-08 05:18:36 +0000 |
commit | 48d17b4c2f6a27d0c02ce1ccf221b781af881528 (patch) | |
tree | f33afa31c0a0cb760d836806cfed4ef66a774997 /epan/dissectors/packet-gsm_sms.c | |
parent | e63c643cb2059fcb3ff21212491019d298f76ee7 (diff) |
From Shmulik Bezalel:
Add support for ucs2 on ussd string.
(Changing the font from Lucida console to Arial dissplaed all chars correctly).
svn path=/trunk/; revision=24029
Diffstat (limited to 'epan/dissectors/packet-gsm_sms.c')
-rw-r--r-- | epan/dissectors/packet-gsm_sms.c | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/epan/dissectors/packet-gsm_sms.c b/epan/dissectors/packet-gsm_sms.c index a7729a6b70..b0624ea29d 100644 --- a/epan/dissectors/packet-gsm_sms.c +++ b/epan/dissectors/packet-gsm_sms.c @@ -672,7 +672,9 @@ dis_field_dcs(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint8 oct, case 0x00: str = "GSM 7 bit default alphabet"; *seven_bit = TRUE; break; - case 0x01: str = "8 bit data"; break; + case 0x01: str = "8 bit data"; + *eight_bit = TRUE; + break; case 0x02: str = "UCS2 (16 bit)"; *ucs2 = TRUE; break; @@ -1820,7 +1822,7 @@ dis_field_ud(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint32 length, gb static guint8 fill_bits_mask[NUM_FILL_BITS_MASKS] = { 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc }; proto_item *item; - proto_item *udh_item; + proto_item *udh_item , *ucs2_item; proto_tree *subtree = NULL; proto_tree *udh_subtree = NULL; guint8 oct; @@ -1828,6 +1830,9 @@ dis_field_ud(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint32 length, gb guint32 out_len; char *ustr; char messagebuf[160]; + gchar *utf8_text = NULL; + GIConv cd; + GError *l_conv_error = NULL; fill_bits = 0; @@ -1909,10 +1914,26 @@ dis_field_ud(tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint32 length, gb tvb_format_text(tvb, offset, length)); } else if (ucs2) + { + if ((cd = g_iconv_open("UTF-8","UCS-2BE")) != (GIConv)-1) + { + utf8_text = g_convert_with_iconv(tvb->real_data + offset, length , cd , NULL , NULL , &l_conv_error); + if(!l_conv_error){ + ucs2_item = proto_tree_add_text(subtree, tvb, offset, length, "UCS-2 to UTF-8 converted text: %s", utf8_text); + }else{ + ucs2_item = proto_tree_add_text(subtree, tvb, offset, length, "%s", "Failed on UCS2 contact wireshark developers"); + } + PROTO_ITEM_SET_GENERATED(ucs2_item); + if(utf8_text) + g_free(utf8_text); + g_iconv_close(cd); + } + else { - /* tvb_get_ephemeral_faked_unicode takes the lengt in number of guint16's */ - ustr = tvb_get_ephemeral_faked_unicode(tvb, offset, (length>>1), FALSE); - proto_tree_add_text(subtree, tvb, offset, length, "%s", ustr); + /* tvb_get_ephemeral_faked_unicode takes the lengt in number of guint16's */ + ustr = tvb_get_ephemeral_faked_unicode(tvb, offset, (length>>1), FALSE); + proto_tree_add_text(subtree, tvb, offset, length, "%s", ustr); + } } } } |