SMS开发中 英文的7bitgsm编码的代码问题

王朝delphi·作者佚名  2006-01-09
窄屏简体版  字體: |||超大  

网上流传的一个编码程序如下:

function EncodeSMSEn(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;

但是这个程序有问题, 在英文字符个数大于7后就不适用

例如发送congradulations! u r %]superman!@##$%^&*())_@!

AT+CMGS=52

> 0011000B81************30000FF2680F1DB7D9687C97576989E7EBBE721501D2407CDEBF0B2BC1D768780A311A9E435A950A9D417

ERROR

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航