82 coding for the vernacular

来源:互联网 发布:网络保密自查报告 编辑:程序博客网 时间:2024/06/05 07:56

Author: Scruffybear, date: 8-June-2009

The SIM sends out  proactive command which include Unicode to display vernacular language menu item, for example chinese character or India local language, but for unicode, one character will occupy two bytes, the proactive command will easily exceed 255 bytes, when the proactive command is too long, the handset will be hanging. My colleague help me solved this problem by using 82 coding.
The reference for the 82 coding is in GSM11.11 'Annex B', you can go there to check the detail.
example:
80 coding
800D2C0D4B0D330D3F0D350D410D210D4D(this is India local language Malayalam)
transfer to 82 coding
82080D00ACCBB3BFB5C1A1CD
explain as below:
82(coding method) 08(length, begin after the base pointer) 0D00(Base pointer)AC(byte one, offset from the base pointer, here is 0D2C-0D00+80=AC)CB(byte two, here is 0D4B-0D00+80=CB) .... ....  
Just like this, lots of bytes had been saved, for this example, the 80 coding occupys 17 bytes, by using 82 coding 12 bytes, saves (17-12)/17=30% bytes, if there are more characters, i think will save more, because the header part will take less percentage in the whole length.
Someone may ask, why in the calculation of offset have to add 0x80? good question, check the AnnexB, you can find the answer, the original text reads,
'if bit 8 of the octet is set to zero, the remaining 7 bits of the octet contain a GSM Default Alphabet character, whereas if bit 8 of the octet is set to one, the remaining seven bits are an offset value added to the base pointer defined in octets three and four, and the resultant 16 bit value is a UCS2 code point, and defines a UCS2 character.'

原创粉丝点击