国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

GSM規范中的部分編碼轉換

2019-11-18 18:24:45
字體:
來源:轉載
供稿:網友

在做跟手機短信相關的東東時候常遇到各種編碼格式數據的轉換,特寫了幾個函數,供參考。

 

function EncodeEnglish(var s:string):string;
var
i,j,len:Integer;
cur:Integer;
t:String;
begin
Result:='';
len:=Length(s);
//j 用于移位計數
i:=1;j:=0;
while i<=len do
begin
if i<len then
//數據變換
cur:=(ord(s[i]) shr j) or ((ord(s[i+1]) shl (7-j)) and $ff)
else
cur:=(ord(s[i]) shr j) and $7f;
FmtStr(t,'%2.2X',[cur]);

Result:=Result+t;
inc(i);
//移位計數達到7位的特別處理
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(ABinaryString);
  for i:= APosStart-1 to APosEnd-1 do
   begin
    AsciiInt:=ord(ABinaryString[i]);
    TmpHexStr:=Format('%x',[AsciiInt]);
    if length(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(HexAscii2DecimalInt(uniHexstr));
   end;    // for
   result := Gb2312 ;
end;


function WideStringToUnicode_Ex(s:WideString;ADestStr:PChar;Limit:integer):integer;
var sLen:integer;
 buffer:array[1..1024] of char;
 tmpchar:char;
 i:integer;
begin
  sLen:=Length(s);
  if sLen>0 then
    begin
     CopyMemory(@buffer,Pointer(s),2*SLen);
     for i:=0 to SLen-1 do
      begin
       tmpchar:=buffer[2*i+1];
       buffer[2*i+1]:=buffer[2*i+2];
       buffer[2*i+2]:=tmpchar;
     end;
     if SLen>Limit then
      SLen:=Limit;
      CopyMemory(ADestStr,@buffer,2*SLen);
      result:=SLen*2;
      result:=2*SLen;
     end
     else
      begin
       result:=0;
      end;
end;


上一篇:取得圖片的透明區域

下一篇:通用查詢組件設計(續二)

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
學習交流
熱門圖片

新聞熱點

疑難解答

圖片精選

網友關注

主站蜘蛛池模板: 浪卡子县| 开平市| 保康县| 大安市| 延安市| 佛山市| 湖口县| 西畴县| 城市| 宝山区| 江津市| 贺州市| 临洮县| 赤水市| 祥云县| 泾源县| 措勤县| 错那县| 铅山县| 台中市| 武宁县| 青海省| 阿尔山市| 安宁市| 宁城县| 江门市| 民勤县| 虎林市| 烟台市| 灵山县| 屯昌县| 沂源县| 滨州市| 涿州市| 体育| 沾化县| 大化| 社会| 阜宁县| 浠水县| 耿马|