16 binary and Chinese characters of the mutual transfer! Go

Source: Internet
Author: User

/****************************16 into Chinese characters ***********************************/
Ansistring Tform1::hex_to_chinese (ansistring Hex)
{
Chinese and English figures mixed together can also be converted
ansistring ret;
for (int i=1; i{
Ansistring TempStr = "0x" + hex.substring (i,2);
RET + = ansistring ((char) (Tempstr.toint ()));
}
return ret;
}
/****************************16 into Chinese characters ***********************************/

/**************************** Kanji to 16 binary ***********************************/
Ansistring Tform1::chinese_to_hex (char* p_bcd, int ilen)
{
Chinese and English figures mixed together can also be converted
ansistring ret = "";
Char Hchar, Lchar, Temp;
for (int i=0; i<ilen; i++)
{
Temp = *p_bcd++;
Hchar = (temp&0xf0) >>4;
Lchar = (temp&0x0f);
if ((Hchar >= 0x00) && (Hchar <= 0x09))
Hchar + = 0x30;
if ((Hchar >= 0x0A) && (Hchar <= 0x0F))
Hchar + = 0x37;
if ((Lchar >= 0x00) && (Lchar <= 0x09))
Lchar + = 0x30;
if ((Lchar >= 0x0A) && (Lchar <= 0x0F))
Lchar + = 0x37;
RET + = ansistring (Hchar);
RET + = ansistring (Lchar);
}
return ret;
}
/**************************** Kanji to 16 binary ***********************************/

void __fastcall Tform1::button4click (tobject *sender)
{
String Strchinese = "Long live Chinese Communist Chanba Party";

D6d0b9fab9b29bbab5b3cdf2cbea This paragraph is a Chinese character in-machine code
String strtemp = Chinese_to_hex (Strchinese.c_str (), strchinese.length ());
Chinese_to_hex () This function turns the in-machine code is not GB code

ShowMessage (strtemp);
strtemp = Hex_to_chinese (strtemp);
ShowMessage (strtemp);
};

16 binary and Chinese characters of the mutual transfer! Go

Related Article

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.