When doing SMS related to mobile phone SMS, it is often encountered in various coding format data, and several functions are written for reference.
Function EncodeEnglish (var s: string): string; varI, j, len: integer; cur: integer; t: string; begin result: = '; len: = length (s); // j is used for shift Count i: = 1; J: = 0; While I <= len do beg I // data transform CUR: = (ORD (S [i]) SHR J) OR ((ORD (S [i 1]) SHL (7-J))) and $ ff) Elsecur: = (ORD (S [i]) SHR J) and $ 7f; fmtstr (t, '% 2.2x', [cur]);
Result: = Result T; INC (I); // Shift count reaches 7 bits of special processing J: = (j 1) MOD 7; if j = 0 THEN INC (I); end; end; // end; function BinaryUniCode2Gb2312 (ABinaryString: PChar; APosStart, APosEnd: integer): string; var i, iLen: integer; AscHexText, TmpHexStr: string; AsciiInt: integer; AscLen, AscUniLen: integer; UniHexstr, GB2312: string; begin iLen: = Length (abineryString); for i: = aposstart-1 to aposend-1 do begin asciiint: = ord (abineryString [i]); tmpHexStr: = format ('% x', [asciiInt]); if longth (TmpHexStr) = 1 then TmpHexStr: = '0' TmpHexStr; AscHexText: = AscHexText TmpHexStr; end; // for AscLen: = Length (AscHexText); AscUniLen: = AscLen div 4; for i: = 0 to AscUniLen-1 do begin Unihexstr: = COPY (AschexText, i * 4 1, 4); // GB2312: = GB2312 UnicoDetogb2312 (unihexstr)); end; // for results: = GB2312;