The garbled problem of OSD transmitting parameter between UTF8 and gb2312 on the web side

Source: Internet
Author: User

(0) The principle and realization of HZK16 lattice font

(1) conversion between UTF8 and Unicode gb2312

(2) GB2312 's expansion GBK realized more text coding like "Watchtower" is not in gb2312.

Ornate Split Line

---------------------------AUTHOR:PKF

----------------------------------time:2014-03

----------------------------------------qq:1327706646

(0) The principle and realization of HZK16 lattice font

  

The 
 HZK16 font is a 16x16 bitmap font that complies with the GB2312 standard, and the HZK16 gb2312-80 supports 6,763 characters and 682 symbols.   One of the first-level Chinese characters have 3,755, according to the order of the sound sequence, two Chinese characters have 3,008, according to the radical arrangement of radicals.  We do not use so many Chinese characters at all in some applications, so we can only extract some fonts for our own use when we apply them.  The 16x16 characters in the HZK16 font need a total of 256 points to display, that is, 32 bytes is required to achieve the purpose of displaying a common Chinese character.   We know that a GB2312 kanji is encoded in two bytes, with a range of 0xa1a1~0xfefe. A1-A9 is the symbol area, B0 to F7 as the Chinese character area.  Each area has 94 characters (note: This is only the license range of the code, not all have font correspondence, such as the symbol area has a lot of coded blank area).  The following is an example of the Chinese character "I," which describes how to find its corresponding 32-byte font data in the HZK16 file.  In front of it, a Chinese character accounts for two bytes, the first byte of which is the area code of the Chinese character, and the next byte is the bit number of the word. Each district records 94 kanji, with the position of the word in the area.  So to find the "I" location in the HZK16 library must get its area code and bit code. Area code: The first byte of the Chinese character -0xa0 (because Chinese character coding is starting from the 0xA0 district, so the file is first from the 0xA0 area, to calculate the relative region code) bit code: The second byte of the Chinese character -0xa0 so we can get the absolute offset position of Chinese characters in HZK16: offset= (94* (Area code-1) + (bit code-1)) *32 Note: 
1. Area code minus 1 because the array starts with 0 and the area code is 1, which starts with 2. ( 94* (Area code-1) + bit-1) is the number of bytes occupied by a Chinese font 3. The last time you multiply 32 is because the character Cuven should record the font information of the word from the 32-byte information in that position (the previous reference to a Chinese character should have 32 bytes display)
 I drew the diagram:|<---16-bit, 2-byte-->|+00000 0000000|    -0x04,0x800000 0 0 00000|    0x0e,0xa00 0000|    0x78,0x900000 0000|    0x08,0x900000 0000 00|    0x08,0x84 0|    0xff,0xfe0000 0000000|    0x08,0x800000 0000|16-0x08,0x900000 0 0 0000|2 byte 0x0a,0x900000 00000|    0x0c,0x60000 0000 000000|    0x18,0x400 0 0 00000|    --0x68,0xa00000, XX 00000|    0x09,0x200000 0 0000 0 00|    0x0a,0x1400 0 000000 0 00| 0x28,0x14000 00000000 00+, 0x10,0x0c So, ' I ' in the HZK16 16*16 lattice Library of the sequence of storage: one row to save, a total of 16 lines, 2 bytes per line, a total of 32 bytes 04 80 0 E A0 (0C)-----------------900A all A0, 0A, and more than ten 0C 
the above arrangement is horizontal, using lattice to take the matrix and vertical arrangement, take touch tool in the attachment
    For (k=0, k<16; k++) {for        (j=0; j<2; J + +) {for            (i=0; i<8; i++) {                flag = buffer[k*2+j]&key[i];                printf ("%s", Flag? " ":" 0 ");
Http://www.cnblogs.com/nbsofer/archive/2012/11/01/2749026.html
Http://blog.chinaunix.net/uid-24219701-id-3343764.html

(1) conversion between UTF8 and Unicode gb2312


int debaifenstrin2int (unsigned char *des,unsigned char *src,int size)
{

unsigned char *psrc = src;
unsigned char *pdes = des;
unsigned char output[100]={0};
unsigned char input[100];

unsigned char *pout=output;
unsigned char in[10]={0};//in[3];
unsigned char out[4]={0};
memset (In,0,sizeof (in));
memset (output,0,sizeof (OutPut));
memset (input,0,sizeof (InPut));

int bufSize = size;
int i,j;
unsigned char *poutput =output;
memset (Pdes,0,strlen (pDes));
while (bufsize>0)
{
memset (In,0,sizeof (in));
memset (output,0,sizeof (OutPut));
if (*psrc== '% ' && (psrc+9)!=null)
{
psrc++;
in[0]=* (PSRC);
psrc++;
in[1]=* (PSRC);
psrc++;
in[2]= ' + ';
Out[0]=htoi (in);

psrc++;
in[0]=* (PSRC);
psrc++;
in[1]=* (PSRC);
psrc++;
in[2]= ' + ';
Out[1]=htoi (in);


psrc++;
in[0]=* (PSRC);
psrc++;
in[1]=* (PSRC);
psrc++;
in[2]= ' + ';
Out[2]=htoi (in);

utf8togb2312 (out, POut, strlen);
*PDES=POUT[0];
pdes++;
*PDES=POUT[1];
pdes++;
bufsize-=9;
}
Else
{
*pdes=0xa3;
pdes++;
*pdes= (*PSRC) +0x80;
pdes++;
psrc++;
bufsize--;
}


}

(2) GB2312 's expansion GBK realized more text coding like "Watchtower" is not in gb2312.

The lookout's understanding is not coded in the gb2312, and the code is given in the GBK.

http://blog.csdn.net/zhouxiaoli521/article/details/5675626

http://ipseeker.cn/tools/pywb.php gb2312 Query

http://www.mytju.com/classcode/tools/encode_utf8.asp UTF8 Query

Http://www.knowsky.com/resource/gb2312tbl.htm

http://www.verydemo.com/demo_c161_i856.html gb2312 query table Unicode gb2312 correspondence table

http://blog.chinaunix.net/uid-20564848-id-73496.html analysis of conversion relationship between Unicode encoding UTF8 encoding and GB2312 encoding

http://blog.csdn.net/zhouxiaoli521/article/details/5675626 GBK Turn gb2312

http://bbs.csdn.net/topics/390090950 DSP end of a[]={' a ', ' B ', ' C '} take array size

The garbled problem of OSD transmitting parameter between UTF8 and gb2312 on the web side

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.