JavaScript错误,缺少十六进制

javascript 错误“缺少十六进制数字”的处理

2008-11-24 13:12:00原因:JS提交数据时出现特殊符号"",javascript中""是个特殊的字符,在很多场合需要转换。

 

参考:

 

例子程序:

 

*Encode for HTML.

 

*/

 

public static String htmlEncoder(Stringstr)

{

  if(str==null|| str.equals(""))

   return"";

  Stringres_str;

  res_str=strReplace(str,"&","&");

  res_str=strReplace(str,""," ");

  res_str=strReplace(str,"<","&lt;");

  res_str=strReplace(str,">","&rt;");

  res_str=strReplace(str,""","&quot;");

  res_str=strReplace(str,"'","'");

  returnres_str;

}

 

/** *//**

 

*Encode for HTML-Text.

 

*/

 

public static String htmlTextEncoder(Stringstr)

{

  if(str==null|| str.equals(""))

   return"";

  Stringres_str;

  res_str=strReplace(str,"&","&amp;");

  res_str=strReplace(str,"<","&lt;");

  res_str=strReplace(str,">","&rt;");

  res_str=strReplace(str,""","&quot;");

  res_str=strReplace(str,"'","'");

  res_str=strReplace(str,"","&nbsp;");

  res_str=strReplace(str,"rn","<br/>");

  res_str=strReplace(str,"r","<br/>");

  res_str=strReplace(str,"n","<br/>");

  returnres_str;

}

 

/** *//**

 

*Encode for URL.

 

*/

 

public static String urlEncoder(String str){

  returnjava.net.URLEncoder.encode(str) ;

}

 

/** *//**

 

*Encode for XML.

 

*/

 

public static String xmlEncoder(String str)

{

  if(str==null|| str.equals(""))

   return"";

  Stringres_str;

  res_str=strReplace(str,"&","&amp;");

  res_str=strReplace(res_str,"<","&lt;");

  res_str=strReplace(res_str,">","&gt;");

  res_str=strReplace(res_str,""","&quot;");

  res_str=strReplace(res_str,"'","&acute;");

  returnres_str;

}

 

/** *//**

 

*Encode for SQL.

 

*/

 

public static String sqlEncoder(String str)

{

  if(str==null|| str.equals(""))

   return"";

  Stringres_str;

  res_str=strReplace(str,"'","''");

  returnres_str;

}

 

/** *//**

 

*Encode for Javascript.

 

*/

 

public static String jsEncoder(String str)

{

  if(str==null|| str.equals(""))

   return"";

  Stringres_str;

  res_str=strReplace(str,"'","'");

  res_str=strReplace(str,""",""");

  res_str=strReplace(str,"rn","");

  res_str=strReplace(str,"n","");

  res_str=strReplace(str,"r","");

  returnres_str;

}

 

html=html+replace(table_list(fileExt,path,2),"","/")+""""

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值