正在阅读:GSM规范中的部分编码转换GSM规范中的部分编码转换

2004-03-23 14:45 出处:CSDN 作者:bjskyhorse 责任编辑:linjixiong

  在做跟手机短信相关的东东时候常遇到各种编码格式数据的转换,特写了几个函数,供参考。

  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;

 


 

察看评论详细内容 我要发表评论
作者笔名简短内容 发表时间
:

键盘也能翻页,试试“← →”键

相关文章

关注我们

最新资讯离线随时看 聊天吐槽赢奖品