Function UNICODETOGB (CONST WSUNICODE: WIDESTRING): String; Var ion: integer; // The number of characters required to convert: String; begin // calculate the number of characters of the conversion Ilen: = Widechartomultibyte (936, 0, PWIDECHAR (WSUNICODE), - 1, NIL, 0, NIL, NIL); // Assign STMP SETLENGTH (STMP, ILEN); ZeromeMory (Pchar (STMP), SIZEOF (CHAR) * ILEN); / / Convert Unicode code to GB code, use API Function Widechartomultibyte Widechartomultibyte (936, Wc_compositeCheck, PWIDECHAR (WSUNICODE), -1, PANSICHAR (STMP), ILEN, '' ', PBOOL (FALSE)); Result: = PCHAR (STMP); END;
Application examples:
Output string
Var strshow; strtemp: widestring; i, len: integer; begin strshow: = '1345 ah SDFDW Fusui mine bureau issued fsdhjh'; strTemp: = strshow;
Len: = Length (strshow);
For i: = 1 to len do begin straTemp [i]: = strshow [len 1 - i];
Strtemp: = UnicoDetogb (strTemp);
ShowMessage (strTemp);