package com.cncaihua.caihuadb.util;public class StringFormat {
public static String getGBString( String strEn ) {
String strGB = "";
try {
byte b[]=strEn.getBytes("ISO-8859-1");
strGB = new String( b );
} catch(Exception e) {
}
return strGB;
}
public static String getSQLString( String str ) {
StringBuffer sb = new StringBuffer( str );
int occur = 0;
occur = sb.indexOf( "'", 0 );
while( occur >= 0 ) {
sb.replace( occur, occur + 1, "''" );
occur = sb.indexOf( "'", occur + 2 );
}
return sb.toString();
}
}
public static String getGBString( String strEn ) {
String strGB = "";
try {
byte b[]=strEn.getBytes("ISO-8859-1");
strGB = new String( b );
} catch(Exception e) {
}
return strGB;
}
public static String getSQLString( String str ) {
StringBuffer sb = new StringBuffer( str );
int occur = 0;
occur = sb.indexOf( "'", 0 );
while( occur >= 0 ) {
sb.replace( occur, occur + 1, "''" );
occur = sb.indexOf( "'", occur + 2 );
}
return sb.toString();
}
}
解决方案 »
- simple_list_item_multiple_choice 里边的CheckBox
- java
- 严重: Exception starting filter opensession!·!!!!! 100分
- S2SH整合出错
- 如何按比例分配 jswing gridbaglayout空间?
- <%@include file=""%>和<jsp:include>哪个速度快些?
- JSF的版本问题
- 求救,数据库连接问题~~~(高分!!)
- 请教jboss3.2.3整合/并发出错的问题
- 在xml中怎么放入多媒体数据?怎么用jdbc在jbuilder中连接oracle数据库获取其中的多媒体数据?
- 哪里能载到pluto的源代码呢?
- String类型最多能接收多大字符串呀?我把5M的附件转换成base64格式的,出现java.lang.OutOfMemoryError
public String toDB(String s){
if(s == null)
return null;
try{
String convert = new String(s.getBytes("GB2312"), "ISO8859_1");
return convert;
}catch(Exception e){}
return null;
}
String newstr = str;
try {
newstr = new String(str.getBytes("ISO-8859-1"));
}
catch (UnsupportedEncodingException uee) {
System.err.println("convert error!");
}
return newstr;
}
%>
<%!
String ex_chinese(String str)
{
if(str==null){
str ="" ;
}
else{
try {
str = new String(str.getBytes("iso-8859-1"),"gb2312") ;
}
catch (Exception ex) {
}
}
return str ;
}
%>