GSM规范中的部分编码转换.net
“随时翻篇”通过精心收集,向本站投稿了2篇GSM规范中的部分编码转换.net,下面是小编为大家整理后的GSM规范中的部分编码转换.net,仅供参考,喜欢可以收藏与分享哟!
篇1:GSM规范中的部分编码转换.net
在做跟手机短信相关的东东时候常遇到各种编码格式数据的转换,特写了几个函数,供参考, 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
在做跟手机短信相关的东东时候常遇到各种编码格式数据的转换,特写了几个函数,供参考。
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 //数据变换 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; UniHexstr,GB2312:string; begin iLen:=Length(ABinaryString); for i:= APosStart-1 to APosEnd-1 do begin AsciiInt:=ord(ABinaryString[i]); TmpHexStr:=Format('%x',[AsciiInt]); if length(TmpHexStr)=1 then TmpHexStr:='0'+TmpHexStr; AscHexText:=AscHexText+TmpHexStr; end; //for AscLen:=Length(AscHexText); AscUniLen:=AscLen div 4; for i:=0 to AscUniLen-1 do begin UniHexstr:=Copy(AscHexText,i*4+1,4); // Gb2312 := Gb2312 + UnicodeToGb2312(HexAscii2DecimalInt(uniHexstr)); end; // for result := Gb2312 ; end; function WideStringToUnicode_Ex(s:WideString;ADestStr:PChar;Limit:integer):integer; var sLen:integer; buffer:array[1..1024] of char; tmpchar:char; i:integer; begin sLen:=Length(s); if sLen>0 then begin CopyMemory(@buffer,Pointer(s),2*SLen); for i:=0 to SLen-1 do begin tmpchar:=buffer[2*i+1]; buffer[2*i+1]:=buffer[2*i+2]; buffer[2*i+2]:=tmpchar; end; if SLen>Limit then SLen:=Limit; CopyMemory(ADestStr,@buffer,2*SLen); result:=SLen*2; result:=2*SLen; end else begin result:=0; end; end; 原文转自:www.ltesting.net
篇2:linux中利用shell实现批量转换文件编码linux操作系统
本例子的原理与php 中的iconv函数有点像我们利用递归再进行批量转换文件编码了,下面看例子,
原理跟简单:递归,iconv
代码如下复制代码#!/bin/sh
TGT=“source_rst”
function fe_convert() {
for file in `ls $1`
do
if [ -d $1“/”$file ]
then
fe_convert $1“/”$file
else
mkdir -p `dirname $TGT“/”$1“/”$file`
iconv -f EUC-JISX0213 -t utf-8 $1“/”$file >$TGT“/”$1“/”$file
fi
done
}
fe_convert src
【GSM规范中的部分编码转换.net】相关文章:






文档为doc格式