in Work&Life

UCS2 code (80,81,82 coding) in SIM card

In the SIM card phone book file (6F3A), the alpha information sometimes needs to code as UCS2, for example to input the Chinese characters or Thai characters, the detail of how to code in UCS2 can be found in GSM11.11, in the part of “Annex B (normative):Coding of Alpha fields in the SIM for UCS2”, can go there to get all the detail, here just give some examples,

example 1, code 81,

Thai: “ผีๆ” in code 81

Unicode of “ผีๆ” is as 0E1C0E350E46, as unicode are two bytes for one character, so the length of the 81 coding is 03, the base pointer is 0x0E00, calculate the Octet 2, get the bits 15 to 8 of the base pointer, it’s 00011100, means 0x1C, to make it simple, left shift one bit of 0x0E, it’s 0x1C,  the offset value to 0x0E00 of the three characters are 0x1C, 0x35, 0x46,  put the bit 8 as 1, then 0x1C, 0x35, 0x46 becomes 0x9C, 0xB5, 0xC6, combine altogether, it’s ’81’+length+Octet 2+offset value of each characters = 81 + 03 + 1C + 9C + B5 + C6 = 81031C9CB5C6

so the 81 coding of “ผีๆ” is 81031C9CB5C6.

example 2, code 82,

Chinese “杜杜1

Unicode of “杜杜1” is 675C675C0031, 82 as code byte, 03 is the length, base pointer as two bytes, 6700, offset value as 0x5C, 0x5C, 0x31, put the bit 8 as 1, and 0x31 as ASCII code, so remain as 0x31, then the three characters offset value as 0xDC, 0xDC, 0x31, combine altogether as 82+03+6700+DC+DC+31 = 82036700DCDC31

Please refer to this link:

Write a Comment