我正在用DELPHI写一个使用TC35收发短消息的程序,由于在网络上找到的DLL或者OCX使用起来都有点问题,可是有看不到其源码,所以不得不自己来写,但是短消息内容需要转换成PDU格式才可以发送(中文),希望可以有人提供给我这两中格式之间转换的算法,我当前了解到的是虽然都是7-BIT的编码格式,但是中文和英文转换的算法不一样。
因为我程序当中会用到中英文同时出现的短消息,所以必须要找一个可以同时转换的算法!希望朋友们帮忙解决帮忙UP。谢谢……

解决方案 »

  1.   

    3Q for your up!
    up
      

  2.   

    中英文同时出现的短消息也是按中文转换
    function TfrmMain.str_Gb2UniCode( text: string ): String;
    var
      i,j,len:Integer;
      cur:Integer;
      t:String;
      ws:WideString;
    begin
      Result:='';
      ws := text;
      len := Length(ws);
      i := 1;
      j := 0;
      while i <= len do
      begin
          cur := ord(ws[i]);
          FmtStr(t,'%4.4X',[cur]);  //BCD转换
        Result := Result+t;
        inc(i);
        //移位计数达到7位的特别处理
        j := (j+1) mod 7;
      end;
    end;   即 msg = "中"
       即 msg = str_Gb2UniCode( msg )
       => msg = "4E2D"
      

  3.   

    function GB2Unicode(GB:string):string;
    var
      s: string;
      i, j, k: integer;
      a: array [1..1000] of char;
    begin
      s:='';
      StringToWideChar(GB, @(a[1]), 500);
      i:=1;
      while ((a[i]<>#0) or (a[i+1]<>#0)) do
      begin
        j:=Integer(a[i]); k:=Integer(a[i+1]);
        s:=s+Copy(Format('%X ',[k*$100+j+$10000]) ,2,4);
        i:=i+2;
      end;
      Result:=s;
    end;function ReadHex(AString:string):integer;
    begin
      Result:=StrToInt('$'+AString)
    end;function UnicodeToAnsi(Unicode: string):string;
    var
      s:string;
      i:integer;
      j,k:string[2];
    begin
      i:=1;
      s:='';
      while i<Length(Unicode)+1 do begin
        j:=Copy(Unicode,i+2,2);
        k:=Copy(Unicode,i,2);
        i:=i+4;
        s:=s+Char(ReadHex(j))+Char(ReadHex(k));
      end;
      if s<>'' then
        s:=WideCharToString(PWideChar(s+#0#0#0#0))
      else
        s:='';
      Result:=s;
    end;这是互相转换的代码
      

  4.   

    有没有人有现成的DLL啊?能提供源代码最好了!to :lion_lh(xmanx) &  ljmanage(过客) 
         谢谢!
      

  5.   

    兄弟,我想省点事啊!你说,要有个DLL多好啊!
    你有没有写过类似的程序啊!?