中国开发网: 论坛: 程序员情感CBD: 贴子 246724
李战
DONE!
[BUG Report]There's a bug in DecodeHeader, it does not support GB2312 Charset which used for Simplified Chinese Characters

Dear Indy Members:
I have found this bug in Indy 10, please correct it. The file is
IdCoderHeader.pas, and you can reference to the following code:

function DecodeHeader(Header: string):string;
......
begin
......
if LEncodingStartPos = 0 then begin
LEncodingStartPos := PosIdx('=?KOI8', Sys.UpperCase(Header), 1); {do not
localize}
end;

//The following was added by leadzen to fix the bug in decoding GB2312
charset
if LEncodingStartPos = 0 then begin
LEncodingStartPos := PosIdx('=?GB2312', Sys.UpperCase(Header), 1); {do
not localize}
end;
//added by leadzen

while LEncodingStartPos > 0 do begin
// Assume we will find the encoding
EncodingFound := True;
......


......

if LEncodingStartPos = 0 then begin
LEncodingStartPos := PosIdx('=?KOI8', Sys.UpperCase(Header),
LPreviousEncodingStartPos + 1); {do not localize}
end;

//The following was added by leadzen to fix the bug in decoding GB2312
charset
if LEncodingStartPos = 0 then begin
LEncodingStartPos := PosIdx('=?GB2312', Sys.UpperCase(Header),
LPreviousEncodingStartPos + 1); {do not localize}
end;
// added by leadzen

// delete whitespace between adjacent encoded words, but only
// if we had an encoding before
if EncodingFound then begin
EncodingBeforeEnd := encodingendpos;
end else begin
EncodingBeforeEnd := -1;
end;

......
end;


That's all

Good luck for you!

李战(leadzen)
李战(leadzen)

相关信息:


欢迎光临本社区,您还没有登录,不能发贴子。请在 这里登录