The Unicode to Chinese character function in Delphi

Source: Internet
Author: User

The recent use of this function, helpless did not find the Delphi brought, online looked for a similar, there is no ready, I need to support the "\u4f00" this format, that is, the front with the standard "\u" so modified a bit.

Here is the decoding function:

It's convenient for those who need it, and I need ^_^ myself.

 ///<summary>    ////// Unicode to Chinese characters, supports automatic filtering of non-Unicode encodings, i.e. non-Unicode encoding does not convert    ///supports only standard type \u4e00 conversions of this format, starting with \u    ///code by ape brother 2015-2-11    ///</summary> functionTmyencode.unicodetochinese (inputstr:string):string;varI:integer;index:integer;temp,top,last:string;beginIndex:=1;  whileindex>=0  Do   beginIndex:= Inputstr. IndexOf ('\u'); ifindex<0  ThenbeginLast :=Inputstr; Result:= result+Last ; Exit;End; Top:= Copy (Inputstr,1, index);//Remove the non-UNIC encoded characters, such as numbers, before the encoded characterstemp:= Copy (inputstr,index+1,6);//remove the code, including \u, such as \u4e3fDelete (temp,1,2); Delete (Inputstr,1, index+6); Result:= result+ top+ Widechar (Strtoint ('$'+temp))   ; End;End;

The Unicode to Chinese character function in Delphi

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.