jmail收信的乱码问题该如何处理???急救
解决方案 »
- c#webbrowser控件的new window事件里怎么得到新窗口的url?
- 用正则表达式取表数据
- C# 怎么实现把SQL2005中的数据导出到Access中
- 有人说说C#里 attribute吗?
- 用C#编程如何嵌入Visio
- PropertyGrid的默认排序是怎么排的
- 有看过 C#技术揭秘 C#高级编程 C#入门经典 的高手朋友们帮帮忙喽
- 谁能帮忙把这段JAVA代码转换成C#,非常感谢!今天结帐
- 此C++代码如何c#实现
- remoting远程事件
- 谁有OUTLOOK的控件,支持.NET2005的,可以给我一下吗,或告诉我一下下载地址,谢谢
- 【新手请教】请诸位高手给一个OracleClient输出到datatable的例子。
/*
sour:解码后的字符
first:QP码的第一个字符
second:QP码的第二个字符
sour为返回值
*/
{
if(first>=65) first-=55;
else first-=48;
if(second>=65) second-=55;
else second-=48;
sour=NULL;
sour=first<<4;
sour|=second;
}这个是c的,网上找来找去就这个了
大大解释下啊,要不改成c#的啊
StreamWriter sr =new StreamWriter(strpath+FILE_NAME,false,Encoding.GetEncoding("GB2312"));
sr.WriteLine(JMsg.Text.ToString());
能不能给段代码啊?
function CheckTxt(const src: string): string; //解码函数
var
i,pos1,pos2,pos3:integer;
post:string;
srclist:TStringList; function Decoder(const s:string):string;
var
s1,s2,s3: integer;
t,v: string;
Encoding: char;
hex,step: integer;
a1: array[1..4] of byte;
b1: array[1..3] of byte;
j: integer;
byte_ptr,real_bytes: integer;
tempedit:TEdit;
begin
s1:=Pos('=?',s);
s2:= 1 ;
hex:= 0 ;
if s1>0 then
for s2:=Length(s)-1 downto 1 do
if Copy(s,s2,2)='?=' then Break;
if (s1=0) or (s2=1) then
begin
Result:=s;
Exit;
end;
t:=Copy(s,s1+2,s2-2-s1);
s3:=Pos('?',t);
Delete(t,1,s3);
if(t='')then
begin
Result:= s;
Exit ;
end ;
Encoding:=t[1];
Delete(t,1,2);
v:='';
step:=0;
case Encoding of
'Q':
while t<>'' do
begin
case step of
0:
begin
case t[1] of
'_': v:=v+' ';
'=': step:=1;
else v:=v+t[1];
end;
end;
1:
begin
if t[1]<='9' then hex:=(Ord(t[1])-Ord('0'))*16
else hex:=(Ord(t[1])-55)*16;
step:=2;
end;
2:
begin
if t[1]<='9' then hex:=hex+(Ord(t[1])-Ord('0'))
else hex:=hex+Ord(t[1])-55;
v:=v+Chr(hex);
step:=0;
end;
end;
Delete(t,1,1);
end;
'B':
begin
byte_ptr:=0;
for j:=1 to Length(t) do
begin
Inc(byte_ptr);
case t[j] of
'A'..'Z': a1[byte_ptr]:=Ord(t[j])-65;
'a'..'z': a1[byte_ptr]:=Ord(t[j])-71;
'0'..'9': a1[byte_ptr]:=Ord(t[j])+4;
'+': a1[byte_ptr]:=62;
'/': a1[byte_ptr]:=63;
'=': a1[byte_ptr]:=64;
end;
if byte_ptr=4 then
begin
byte_ptr:=0;
real_bytes:=3;
if a1[1]=64 then real_bytes:=0;
if a1[3]=64 then
begin
a1[3]:=0;
a1[4]:=0;
real_bytes:=1;
end;
if a1[4]=64 then
begin
a1[4]:=0;
real_bytes:=2;
end;
b1[1]:=a1[1]*4+(a1[2] div 16);
b1[2]:=(a1[2] mod 16)*16+(a1[3]div 4);
b1[3]:=(a1[3] mod 4)*64 +a1[4];
if (real_bytes>0) then
v:= v + chr(b1[1]) ;
if (real_bytes>1) then
v:= v + chr(b1[2]) ;
if (real_bytes>2) then
v:= v + chr(b1[3]) ;
end;
end;
end;
end;
Result:=Copy(s,1,s1-1)+v+Copy(s,s2+2,999); tempedit:=TEdit.Create(nil);
try
tempedit.Width:=0;
tempedit.Height:=0;
tempedit.Visible:=True;
tempedit.Text:=Result;
Result:=tempedit.Text;
finally
FreeAndNil(tempedit);
end;
if Pos('***SPAM***',Result)>0 then
result:=copy(result,pos('-',result)+1,length(result)-pos('-',result));
end;
begin
pos1:=Pos('=?',src);
pos2:= 1 ;
if pos1>0 then
for pos2:=Length(src)-1 downto 1 do
if Copy(src,pos2,2)='?=' then Break;
if (pos1=0) or (pos2=1) then
begin
Result:=src;
Exit;
end; post:=Copy(src,pos1+2,pos2-2-pos1);
pos3:=Pos('?',post);
Delete(post,1,pos3);
if(post='')then
begin
Result:=src;
Exit ;
end ; srclist:=TStringList.Create;
try
srclist.Clear;
StrtoStrlist(' ',src,srclist);
Result:='';
for i:=0 to srclist.Count-1 do
begin
post:=srclist.Strings[i];
Result:=Result+Decoder(post);
end;
finally
srclist.Free;
end;
end;
http://community.csdn.net/Expert/topic/4819/4819316.xml?temp=.2004969
上有几个c#的解码,不过编出来还是乱码