|
|
4#

楼主 |
发表于 2008-9-26 18:40:03
|
只看该作者

publicGB2BIG5Filter(Streamsink)
{
_sink=sink;
}
//ThefollowingmembersofStreammustbeoverriden.
publicoverrideboolCanRead
{
get{returntrue;}
}
publicoverrideboolCanSeek
{
get{returntrue;}
}
publicoverrideboolCanWrite
{
get{returntrue;}
}
publicoverridelongLength
{
get{return0;}
}
publicoverridelongPosition
{
get{return_position;}
set{_position=value;}
}
publicoverridelongSeek(longoffset,System.IO.SeekOrigindirection)
{
return_sink.Seek(offset,direction);
}
publicoverridevoidSetLength(longlength)
{
_sink.SetLength(length);
}
publicoverridevoidClose()
{
_sink.Close();
}
publicoverridevoidFlush()
{
_sink.Flush();
}
publicoverrideintRead(byte[]buffer,intoffset,intcount)
{
return_sink.Read(buffer,offset,count);
}
//GB2312936
//Big5950
publicoverridevoidWrite(byte[]buffer,intoffset,intcount)
{
Encodinge=Encoding.GetEncoding(936);
stringstr=e.GetString(buffer,offset,count);
for(inti=0;i<str.Length;i++)
{
intj=_sGB.IndexOf(str);
if(j!=-1)str=str.Replace(_sGB[j],_tGB[j]);
}
e=Encoding.GetEncoding(950);
_sink.Write(e.GetBytes(str),0,e.GetByteCount(str));
}
} |
|