to: leitz(寻找快乐的人) 我在Application.BeginRequest中将Requset.Filter 修改了, 但是无法实现截取客户端发来的繁体字啊!to: panyee(快乐王子) 我转换字体使用的是这种方法,但是,我现在是截取不到客户端传来的 繁体字谢谢
这是我写的类,我怀疑是Read(byte[] ....) 函数的错误 Request.Filter = new Encode.RequestTrad(); =============================================================using System; using System.Text; using System.IO; using System.IO.IsolatedStorage; using System.Runtime.Remoting;namespace Encode { public class RequestToSimp : // This filter changes all characters passed through it to uppercase. { private Stream _sink; //private long _position; private Encoding e=Encoding.GetEncoding("utf-8"); private const string _sGB=@"皑蔼碍爱袄奥坝罢摆败颁办绊帮绑镑谤剥饱宝报鲍辈贝钡狈备惫绷笔毕毙币闭边编贬变辩辫标鳖别瘪濒滨宾摈饼并拨钵铂驳卜补财参蚕残惭惨灿苍舱仓沧厕钔钗钕钛钣钤钫钪钭钬钯钰钲钴钶钸钹钺钼钽钿铄铈铉铊铋铌铍铎铐铑铒铕铖铗铙铛铟铠铢铤铥铧铨铪铩铫铮铯铳铴铵铷铹铼铽铿锂锆锇锉锊锒锓锔锕锖锛锞锟锢锩锬锱锲锴锶锷锸锼锾镂锵镆镉镌镏镒镓镔镖镗镘镙镛镞镟镝镡镤镦镧镨镪镫镬镯镱镳锺穑鸠鸢鸨鸩鸪鸫鸬鸲鸱鸶鸸鸷鸹鸺鸾鹁鹂鹄鹆鹇鹈鹉鹌鹎鹑鹕鹗鹞鹣鹦鹧鹨鹩鹪鹫鹬鹭鹳疖疠痨痫瘅瘗瘿瘾癞癫窦窭裆裢裣裥褛褴襁皲耧聍聩顸颀颃颉颌颏颔颚颛颞颟颡颢颦虬虮虿蚬蚝蛎蛏蛱蛲蛳蛴蝈蝾蝼罂笃笕笾筚筝箦箧箨箪箫篑簖籁舣舻袅羟糁絷麸趱酽酾鹾趸跄跖跞跷跸跹跻踬踯蹑蹒蹰躏躜觞觯靓雳霁霭龀龃龅龆龇龈龉龊龌黾鼋鼍隽雠銮錾鱿鲂鲅鲈稣鲋鲎鲐鲒鲔鲕鲚鲛鲞鲟鲠鲡鲢鲣鲥鲦鲧鲨鲩鲫鲭鲮鲰鲱鲲鲳鲵鲶鲷鲻鲽鳄鳅鳆鳇鳌鳍鳎鳏鳐鳓鳔鳕鳗鳜鳝鳟鳢鞑鞯鹘髅髋髌魇魉飨餍鬓黩黪鼹"; private const string _tGB=@"皚藹礙愛襖奧壩罷擺敗頒辦絆幫綁鎊謗剝飽寶報鮑輩貝鋇狽備憊繃筆畢斃幣閉邊編貶變辯辮標鱉別癟瀕濱賓擯餅並撥缽鉑駁蔔補財參蠶殘慚慘燦蒼艙倉滄廁側冊測層詫攙摻蟬饞讒纏鏟產闡顫場嘗長償腸廠暢鈔車徹塵陳襯撐稱懲誠騁癡遲馳恥齒熾沖爭幀鄭證織職執紙摯擲幟質滯鍾終種腫眾謅軸皺晝驟豬諸誅燭矚囑貯鑄築駐專磚轉賺樁莊裝妝壯狀錐贅墜綴諄著濁茲資漬蹤綜總縱鄒詛組鑽亙羋嗇厙厴靨贗匭匱賾剄劌剴傴倀黽黿鼉雋讎鑾鏨魷魴鮁鱸穌鮒鱟鮐鮚鮪鮞鱭鮫鯗鱘鯁鱺鰱鰹鰣鰷鯀鯊鯇鯽鯖鯪鯫鯡鯤鯧鯢鯰鯛鯔鰈鱷鰍鰒鰉鼇鰭鰨鰥鰩鰳鰾鱈鰻鱖鱔鱒鱧韃韉鶻髏髖髕魘魎饗饜鬢黷黲鼴";
//设置字符编码 public string Encode { get { return e.EncodingName; } set { e = Encoding.GetEncoding(value); } }
public RequestToSimp(Stream sink) { //System.Web.HttpContext.Current.Response.ContentEncoding=Encoding.GetEncoding(950); _sink = sink;
} // The following members of Stream must be overriden. public override bool CanRead { get { return true; } } public override bool CanSeek { get { return true; } } public override bool CanWrite { get { return true; } }
public override long Length { get { return _sink.Length; } }// public override long Position // { // get { return _position; } // set { _position = value; } // } public override IAsyncResult BeginRead( byte[] buffer, int offset, int count, AsyncCallback callback, object state) { base.BeginRead(buffer,offset,count,callback,state); return _sink.BeginRead(buffer,offset,count,callback,state); } public override IAsyncResult BeginWrite( byte[] buffer, int offset, int count, AsyncCallback callback, object state ) { base.BeginWrite(buffer,offset,count,callback,state); return _sink.BeginWrite(buffer,offset,count,callback,state);
} public override ObjRef CreateObjRef( Type requestedType ) {
return _sink.CreateObjRef(requestedType); } public override int EndRead( IAsyncResult asyncResult ) { base.EndRead( asyncResult); return _sink.EndRead( asyncResult); } public override void EndWrite( IAsyncResult asyncResult ) { base.EndWrite(asyncResult); _sink.EndWrite(asyncResult); } // public object GetLifetimeService() // { // return _sink.GetLifetimeService(); // } public override object InitializeLifetimeService() { base.InitializeLifetimeService(); return _sink.InitializeLifetimeService(); } public override int ReadByte() { base.ReadByte(); return _sink.ReadByte(); } public override long Position { get { return _sink.Position; } set { _sink.Position = value; } } public override long Seek(long offset, System.IO.SeekOrigin direction) { return _sink.Seek(offset, direction); } public override void SetLength(long length) { _sink.SetLength(length); } public override void Close() { _sink.Close(); } public override void Flush() { _sink.Flush(); } public override int Read(byte[] buffer, int offset, int count) { string str=e.GetString(buffer,offset,count); for(int i=0;i<str.Length;i++) { int j=_tGB.IndexOf(str[i]); if(j!=-1)str=str.Replace(_tGB[j],_sGB[j]); } base.Read(e.GetBytes(str), 0,e.GetByteCount(str)); return _sink.Read(e.GetBytes(str), 0,e.GetByteCount(str)); } // The Write method actually does the filtering. public override void Write(byte[] buffer, int offset, int count) {
byte[] bytes = System.Text.Encoding.GetEncoding("big5").GetBytes(strBig5);
System.Text.Encoding big5Encoding = System.Text.Encoding.GetEncoding("big5");
System.Text.Encoding gb2312Encoding = System.Text.Encoding.GetEncoding("gb2312");
bytes = System.Text.Encoding.Convert(big5Encoding,gb2312Encoding, bytes);
string strGB2312 = System.Text.Encoding.GetEncoding("gb2312").GetString(bytes);
我在Application.BeginRequest中将Requset.Filter 修改了,
但是无法实现截取客户端发来的繁体字啊!to: panyee(快乐王子)
我转换字体使用的是这种方法,但是,我现在是截取不到客户端传来的 繁体字谢谢
Request.Filter = new Encode.RequestTrad();
=============================================================using System;
using System.Text;
using System.IO;
using System.IO.IsolatedStorage;
using System.Runtime.Remoting;namespace Encode
{ public class RequestToSimp :
// This filter changes all characters passed through it to uppercase.
{
private Stream _sink;
//private long _position;
private Encoding e=Encoding.GetEncoding("utf-8"); private const string _sGB=@"皑蔼碍爱袄奥坝罢摆败颁办绊帮绑镑谤剥饱宝报鲍辈贝钡狈备惫绷笔毕毙币闭边编贬变辩辫标鳖别瘪濒滨宾摈饼并拨钵铂驳卜补财参蚕残惭惨灿苍舱仓沧厕钔钗钕钛钣钤钫钪钭钬钯钰钲钴钶钸钹钺钼钽钿铄铈铉铊铋铌铍铎铐铑铒铕铖铗铙铛铟铠铢铤铥铧铨铪铩铫铮铯铳铴铵铷铹铼铽铿锂锆锇锉锊锒锓锔锕锖锛锞锟锢锩锬锱锲锴锶锷锸锼锾镂锵镆镉镌镏镒镓镔镖镗镘镙镛镞镟镝镡镤镦镧镨镪镫镬镯镱镳锺穑鸠鸢鸨鸩鸪鸫鸬鸲鸱鸶鸸鸷鸹鸺鸾鹁鹂鹄鹆鹇鹈鹉鹌鹎鹑鹕鹗鹞鹣鹦鹧鹨鹩鹪鹫鹬鹭鹳疖疠痨痫瘅瘗瘿瘾癞癫窦窭裆裢裣裥褛褴襁皲耧聍聩顸颀颃颉颌颏颔颚颛颞颟颡颢颦虬虮虿蚬蚝蛎蛏蛱蛲蛳蛴蝈蝾蝼罂笃笕笾筚筝箦箧箨箪箫篑簖籁舣舻袅羟糁絷麸趱酽酾鹾趸跄跖跞跷跸跹跻踬踯蹑蹒蹰躏躜觞觯靓雳霁霭龀龃龅龆龇龈龉龊龌黾鼋鼍隽雠銮錾鱿鲂鲅鲈稣鲋鲎鲐鲒鲔鲕鲚鲛鲞鲟鲠鲡鲢鲣鲥鲦鲧鲨鲩鲫鲭鲮鲰鲱鲲鲳鲵鲶鲷鲻鲽鳄鳅鳆鳇鳌鳍鳎鳏鳐鳓鳔鳕鳗鳜鳝鳟鳢鞑鞯鹘髅髋髌魇魉飨餍鬓黩黪鼹";
private const string _tGB=@"皚藹礙愛襖奧壩罷擺敗頒辦絆幫綁鎊謗剝飽寶報鮑輩貝鋇狽備憊繃筆畢斃幣閉邊編貶變辯辮標鱉別癟瀕濱賓擯餅並撥缽鉑駁蔔補財參蠶殘慚慘燦蒼艙倉滄廁側冊測層詫攙摻蟬饞讒纏鏟產闡顫場嘗長償腸廠暢鈔車徹塵陳襯撐稱懲誠騁癡遲馳恥齒熾沖爭幀鄭證織職執紙摯擲幟質滯鍾終種腫眾謅軸皺晝驟豬諸誅燭矚囑貯鑄築駐專磚轉賺樁莊裝妝壯狀錐贅墜綴諄著濁茲資漬蹤綜總縱鄒詛組鑽亙羋嗇厙厴靨贗匭匱賾剄劌剴傴倀黽黿鼉雋讎鑾鏨魷魴鮁鱸穌鮒鱟鮐鮚鮪鮞鱭鮫鯗鱘鯁鱺鰱鰹鰣鰷鯀鯊鯇鯽鯖鯪鯫鯡鯤鯧鯢鯰鯛鯔鰈鱷鰍鰒鰉鼇鰭鰨鰥鰩鰳鰾鱈鰻鱖鱔鱒鱧韃韉鶻髏髖髕魘魎饗饜鬢黷黲鼴";
//设置字符编码
public string Encode
{
get
{
return e.EncodingName;
}
set
{
e = Encoding.GetEncoding(value);
}
}
public RequestToSimp(Stream sink)
{
//System.Web.HttpContext.Current.Response.ContentEncoding=Encoding.GetEncoding(950);
_sink = sink;
} // The following members of Stream must be overriden.
public override bool CanRead
{
get { return true; }
} public override bool CanSeek
{
get { return true; }
} public override bool CanWrite
{
get { return true; }
}
{
get { return _sink.Length; }
}// public override long Position
// {
// get { return _position; }
// set { _position = value; }
// } public override IAsyncResult BeginRead(
byte[] buffer,
int offset,
int count,
AsyncCallback callback,
object state) {
base.BeginRead(buffer,offset,count,callback,state);
return _sink.BeginRead(buffer,offset,count,callback,state);
} public override IAsyncResult BeginWrite(
byte[] buffer,
int offset,
int count,
AsyncCallback callback,
object state
)
{
base.BeginWrite(buffer,offset,count,callback,state);
return _sink.BeginWrite(buffer,offset,count,callback,state);
} public override ObjRef CreateObjRef(
Type requestedType
)
{
return _sink.CreateObjRef(requestedType);
} public override int EndRead(
IAsyncResult asyncResult
)
{
base.EndRead( asyncResult);
return _sink.EndRead( asyncResult);
} public override void EndWrite(
IAsyncResult asyncResult
)
{
base.EndWrite(asyncResult);
_sink.EndWrite(asyncResult);
}
// public object GetLifetimeService()
// {
// return _sink.GetLifetimeService();
// } public override object InitializeLifetimeService()
{
base.InitializeLifetimeService();
return _sink.InitializeLifetimeService();
} public override int ReadByte()
{
base.ReadByte();
return _sink.ReadByte();
}
public override long Position
{
get { return _sink.Position; }
set { _sink.Position = value; }
} public override long Seek(long offset, System.IO.SeekOrigin direction)
{
return _sink.Seek(offset, direction);
} public override void SetLength(long length)
{
_sink.SetLength(length);
} public override void Close()
{
_sink.Close();
} public override void Flush()
{
_sink.Flush();
} public override int Read(byte[] buffer, int offset, int count)
{
string str=e.GetString(buffer,offset,count);
for(int i=0;i<str.Length;i++)
{
int j=_tGB.IndexOf(str[i]);
if(j!=-1)str=str.Replace(_tGB[j],_sGB[j]);
}
base.Read(e.GetBytes(str), 0,e.GetByteCount(str));
return _sink.Read(e.GetBytes(str), 0,e.GetByteCount(str));
} // The Write method actually does the filtering.
public override void Write(byte[] buffer, int offset, int count)
{
// string str=e.GetString(buffer,offset,count);
// for(int i=0;i<str.Length;i++)
// {
// int j=_tGB.IndexOf(str[i]);
// if(j!=-1)str=str.Replace(_tGB[j],_sGB[j]);
// }
//e=Encoding.GetEncoding(System.Web.HttpContext.Current.Response.Charset);
_sink.Write(e.GetBytes(str), 0, e.GetByteCount(str));
} }
}
是继承于哪个类?
但是我跟踪了 Request.Filter ,它是 System.Web.StreamHtmlInputScore 类
是.net 一个not pulice 类,无法创建实例