國標2312轉換UCS2碼

2021-04-13 11:02:26 字數 1251 閱讀 2832

#define gb_offset_number 94  //the number of one gb zone.

#define gb_min_zone   0xa0 //min value of the zone number of gb code

#define gb_max_zone   0xf8 //max value of the zone number of gb code

#define gb_min_offset  0xa1 //min value of the offset number of gb code

#define gb_max_offset  0xff //max value of the offset number of gb code

#define max_offset_in_table 8272 //the max offset of the conversion table.

#ifdef win32

#define use_word(v)  ((((v) >> 8) | ((v) << 8)) & 0xffff)

#else

#define use_word(v)  (v)

#endif

const unsigned short gb2312_to_ucs2_table =

; /* end of gb2312_to_ucs2_table */  

unsigned long  gb2312_to_ucs2(              // return the ucs2 count

const unsigned  char *  gb2312,         // the pointer that contain the gb2312 string

unsigned int            gb2312_size,    // the bytes count that the gb2312 string length

unsigned short       *  ucs2,           // the buffer that store the converted ucs2

unsigned long           max_ucs2)       // max ucs2 buffer size

else if( (tmp < 0xf8) && (tmp >= 0xa0) )

else

}else

}*ucs2 = 0;

return ucs2_count;

}

utf8 GB2312轉換函式(c )

實現多種編碼方式的轉換 要轉換的字元 從哪種方式轉換,如utf 8 轉換成哪種編碼,如gb2312 轉換結果 string convertstr string str,string from,string to byte bs system.text.encoding.getencoding fro...

解決GB2312 GBK UTF 8轉換問題

gb2312 資訊交換用漢字編碼字符集 不支援生僻字的字符集,這是其本身限制的問題 gbk 漢字編碼字符集,向下與gb2312相容 支援生僻字的字符集 utf 8 是一種針對unicode的可變長度字元編碼,又稱萬國碼。現在手上乙個專案正在上傳基礎資料,客戶反饋某資料上傳失敗,我研究之後發現是客戶上...

20141011 轉換習題2

習題要求 依次鍵盤輸入每個人的名字,加年齡,之後彙總列印出來,之後求年齡和列印出來。需要將名字和年齡分別定義賦值。名字定義為引用型,string m1 console.readline 年齡則需要定義為值型 double n1 convert.todouble console.readline 因為...