在做跟手机短信相关的东东时候常遇到各种编码格式数据的转换,特写了几个函数,供参考。
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;
Java Asp PHP .Net XML C/C++ CGI VB Jsp J2ee J2se J2me EJB Servlet Tomcat Resin Struts Weblogic Eclipse ANT GUI JMS Web servise IDEA Webphere Hibernate Spring Jboss Applet Swing Socket Javamail Perl Ajax P2P 安全 模式 框架 测试 开源 游戏
Windows XP Windows 2000 Windows 2003 Windows Me Windows 9.x Linux UNIX 注册表 操作系统 服务器 应用服务器