网上流传的一个编码程序如下:
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