编码问题

在使用ComponentArt.Web.UI.dll中,发现TreeView控件中的改名操作不支持中文,总是返回一些字符编码,如“中”就显示为%u4e2d,上网查了半天发现原来这个是一个UrlEncode,并且是Unicode编码的。这样就好办了,写了两个方法方便调用:


        
public   static   string  UrlDecodeUnicode( string  urlToDecode)
        
{
            
if(IsNullorEmpty(urlToDecode))
                
return urlToDecode;

            
return System.Web.HttpUtility.UrlDecode(urlToDecode, Encoding.UTF8);
        }



        
public   static   string  UrlEncodeUnicode( string  urlToEncode)
        
{
            
if(IsNullorEmpty(urlToEncode))
                
return urlToEncode;

            
return System.Web.HttpUtility.UrlEncodeUnicode(urlToEncode);
        }

在NodeRenamed事件中把传回的值用UrlDecodeUnicode解码一下就行了。

你可能感兴趣的:(编码)