SIM卡中UCS2编码的三种格式(80,81,82)分析
http://hi.baidu.com/youren4548/blog/item/fa08bd1bf61005058618bf1d.html 操作SIM卡中的数据操作主要有两个地方,一个是短信操作,还有一个通讯录操作,两种编码略有差别: 1、短信息操作: 在短信息中,默认一条短信的最大长度为140个字节。 纯ASCII字符
http://hi.baidu.com/youren4548/blog/item/fa08bd1bf61005058618bf1d.html
操作SIM卡中的数据操作主要有两个地方,一个是短信操作,还有一个通讯录操作,两种编码略有差别:
1、短信息操作:
在短信息中,默认一条短信的最大长度为140个字节。
纯ASCII字符主要采用7-bit编码格式,即只是利用了字符的后7位数据,这样160个ASCII字符只占用140个字节。这样我们手机的一条短信就可以发送160个ASCII字符了。
包含汉字的字符采用UCS2编码格式,即UNICODE的2字节编码格式。样每个字符占用两个字节,只要短信中包含中文,整条短信的字符都要采用UCS2编码,这样整个短信最多就只能发送70个字符了。
2、通讯录操作:
通讯录中的姓名长度限制不一样,本人使用的TD模块限制长度为14个字节。
单独的ASCII字符正常都使用8-bit编码格式,即每个字节都占用8位,这也是最为正常的存储格式了。
如果包含中文等字符,则正常采用80编码格式,即整个姓名字符以80开头,后面跟上UCS2数据,但有些情况下又会采用81或者82开头。
a) 80 开头:
80开头的为ucs2格式(注意:后面的字符必须有中文才行,否则可能是以80开头的纯ASCII字符串),大头在前,小头在后。
例1:中国
UNICODE编码为:4E2D56FD
用ucs2的80方案表示是:804E2D56FD
例2:杜10娘
UNICODE编码为:675C003100305A18
用ucs2的80方案表示是:80675C003100305A18
显然只要有中文,数字也得占用两个字节。
b) 81 开头:
81开头的格式中,包含一个基址(一个字节)。有这个基址,就可以用一个字节表示一个ucs2字符了。
在格式上,81是标识,后一个字节表示整个字符串长度,再后面一个字节是基址,再往后的就都是数据了。先举一例:
例3:杜杜杜
UNICODE编码为:675C675C675C
用ucs2的80方案表示是:80675C675C675C
用ucs2的81方案表示是:8103CEDCDCDC
分析一下UCS2的81方案:8103CEDCDCDC
81:为标记
03:表示整个字符串为3个字符
CE:一个字节为基址。解析的方法为:将基址(CE)左移七位,并将最高位置为0,最低位再补一个0(这样就16位啦)。此时基
址变为0x6700,然后再判断后面的数据字节。
DCDCDC:3个数据字节 DC, DC, DC 。如果数据字节的最高位为0,则认为此字节是一个ASCII字符。如果数据字节的最高位为
1,则低7位为基址的一个偏移,实际的UCS2字符为基址加上这个偏移值。由于此处三个数据字节最高位都为1,则实际的3个字符的
偏移值为:5C, 5C, 5C。实际的UCS2编码为: 0x675C 0x675C 0x675C, 此处我们就看的明白了。
例4:一丁丂七丄丅 (注:这些字符属于GBK字符集)
UNICODE编码为:4E004E014E024E034E044E05
用ucs2的80方案表示是:804E004E014E024E034E044E05
用ucs2的81方案表示是:81069C808182838485
分析一下UCS2的81方案:81069C808182838485
81:为标记
06:表示整个字符串为6个字符
9C:一个字节为基址。解析的方法为:将基址(9C)左移七位,并将最高位置为0,最低位再补一个0(这样就16位啦)。此时基址
变为0x4E00,然后再判断后面的数据字节。
808182838485:6个数据字节 80,81,82,83,84,85 。由于此处六个数据字节最高位都为1,则实际的6个字符的偏移值为:00,
01,02,03,04,05。实际的UCS2编码为:0x4E00,0x4E01,0x4E02,0x4E03,0x4E04,0x4E05。 OK。
c) 82 开头:
82开头的格式中,包含一个基址(两个字节)。有这个基址,就可以用一个字节表示一个ucs2字符了。
在格式上,81是标识,后一个字节表示整个字符串长度,再后面两个字节是基址,再往后的就都是数据了。先举一例:
例5:8025EF芳
UNICODE编码为:00380030003200350045004682B3
用ucs2的80方案表示是:8000380030003200350045004682B3
用ucs2的81方案表示是:(因为格式的限制,最多容纳128个中文和127个英文,所以此处无法用81格式表示)
用ucs2的82方案表示是:82078280383032354546B3
分析一下UCS2的82方案:82078280383032354546B3
82:为标记
07:表示整个字符串为7个字符
8280:两个字节为基址。
383032354546B3:7个数据字节 38,30,32,35,45,46,B3。如果数据字节的最高位为0,则认为此字节是一个ASCII字符。如果
数据字节的最高位为1,低7位为基址的一个偏移,实际的UCS2字符为基址加上这个偏移值。由于此处七个数据字节的前六个字节最高
位为0,所以表示6个ASCII字符0x38,0x30,0x32,0x35,0x45,即8,0,2,5,E,F。第七个字节的最高位为1,则此数据的
偏移值为0x33,需要加上基址 0x8280,UCS2编码为0x82B3(芳)
例6:杜杜1
UNICODE编码为:675C675C0031
用ucs2的80方案表示是:80675C675C0031
用ucs2的81方案表示是:8103CEDCDC31
用ucs2的82方案表示是:82036700DCDC31
分析一下UCS2的82方案:82036700DCDC31
82:为标记
03:表示整个字符串为6个字符
6700:两个字节为基址。
DCDC31:36个数据字节 DC,DC,31。由于此处三个字节的前两个字节最高位为1,则此数据的偏移值为0x5C,需要加上基址
0x6700,UCS2编码为:0x675C(杜)。第三个字节的最高位为0,所以表示一个ASCII字符:0x31,即 1 。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



QQ email: QQ number@qq.com, English QQ email: English or numbers@qq.com, foxmail email account: set up your own account@foxmail.com, mobile phone email account: mobile phone number@qq.com. Tutorial Applicable Model: iPhone13 System: IOS15.3 Version: QQ Mailbox 6.3.3 Analysis 1QQ mailbox has four formats, commonly used QQ mailbox: QQ number@qq.com, English QQ mailbox: English or numbers@qq.com, foxmail Email account: set up your own account@foxmail.com, mobile phone email account: mobile phone number@qq.com. Supplement: What is qq mailbox? 1 The earliest QQ mailbox was only between QQ users

How to implement HTTP streaming in C++? Create an SSL stream socket using Boost.Asio and the asiohttps client library. Connect to the server and send an HTTP request. Receive HTTP response headers and print them. Receives the HTTP response body and prints it.

Title: Analysis of the reasons and solutions for why the secondary directory of DreamWeaver CMS cannot be opened. Dreamweaver CMS (DedeCMS) is a powerful open source content management system that is widely used in the construction of various websites. However, sometimes during the process of building a website, you may encounter a situation where the secondary directory cannot be opened, which brings trouble to the normal operation of the website. In this article, we will analyze the possible reasons why the secondary directory cannot be opened and provide specific code examples to solve this problem. 1. Possible cause analysis: Pseudo-static rule configuration problem: during use

Hellofolks, my name is Luga, and today we will talk about technologies related to the artificial intelligence (AI) ecological field - GenAI. Facing the challenges of rapid technological innovation and differentiated business scenarios, traditional coding methods have begun to become acclimated and cannot fully cope with the growing demands. At the same time, emerging general-purpose GenAI (artificial intelligence technology) has great potential to meet this demand. As a representative of artificial intelligence technology, GenAI has begun to be widely used in all walks of life with its strong potential and capabilities. It can automatically learn and adapt to coding needs in different scenarios, greatly improving coding efficiency and quality. Through deep learning and model optimization, GenAI is able to accurately understand different

Solution: 1. Retry: You can wait for a period of time and try again, or refresh the page; 2. Check the server load: Check the server's CPU, memory and disk usage. If the capacity limit is exceeded, you can try to optimize the server configuration or increase the capacity. Server resources; 3. Check server maintenance and upgrades: You can only wait until the server returns to normal; 4. Check network connection: Make sure the network connection is stable, check whether the network device, firewall or proxy settings are correct; 5. Ensure cache or CDN configuration Correct; 6. Contact the server administrator, etc.

Title: Is Tencent’s main programming language Go: An in-depth analysis. As China’s leading technology company, Tencent has always attracted much attention in its choice of programming languages. In recent years, some people believe that Tencent mainly adopts Go as its main programming language. This article will conduct an in-depth analysis of whether Tencent's main programming language is Go, and give specific code examples to support this view. 1. Application of Go language in Tencent Go is an open source programming language developed by Google. Its efficiency, concurrency and simplicity are loved by many developers.

Implementing HTTP file upload security in Golang requires following these steps: Verify file type. Limit file size. Detect viruses and malware. Store files securely.

Explore the causes and solutions of HTTP status code 404 Introduction: In the process of browsing the web, we often encounter HTTP status code 404. This status code indicates that the server was unable to find the requested resource. In this article, we will explore the causes of HTTP status code 404 and share some solutions. 1. Reasons for HTTP status code 404: 1.1 Resource does not exist: The most common reason is that the requested resource does not exist on the server. This may be caused by the file being accidentally deleted, incorrectly named, incorrectly pathed, etc.
