| String sEnglish = “apple”; String sChinese = “苹果”; String s = “苹果 apple ”; |
| out.println(string); |
| <%@page contentType=”text/html;charset=gb2312” %> |
| String s1 = request.getParameter(“keyword”); String s2 = new String(s1.getBytes(“ISO-8859-1”),”GBK”); |
背景 | |||
| 开发环境 | JDK1.15 | Vcafe2.0 | JPadPro |
| 服务器端 | NT IIS | Sybase System | Jconnect(JDBC) |
| 客户端 | IE5.0 | Pwin98 | |
| dbstr2 = results.getString(1); //After reading the result from DB server,converting it to string. dbbyte1 = dbstr2.getBytes(“iso-8859-1”); dbstr1 = new String(dbbyte1); |
| sqlstmt = tf_input.getText(); //Before sending statement to DB server,converting it to sql statement. dbbyte1 = sqlstmt.getBytes(); sqlstmt = newString(dbbyte1,”iso-8859-1”); _stmt = _con.createStatement(); _stmt.executeUpdate(sqlstmt); …… |
| import java.io.*; import java.util.*; public class gb2big5 { static int iCharNum=0; public static void main(String[] args) { System.out.println("Input GB2312 file, output Big5 file."); if (args.length!=2) { System.err.println("Usage: jview gb2big5 gbfile big5file"); System.exit(1); String inputString = readInput(args[0]); writeOutput(inputString,args[1]); System.out.println("Number of Characters in file: "+iCharNum+"."); } static void writeOutput(String str, String strOutFile) { try { FileOutputStream fos = new FileOutputStream(strOutFile); Writer out = new OutputStreamWriter(fos, "Big5"); out.write(str); out.close(); } catch (IOException e) { e.printStackTrace(); e.printStackTrace(); } } static String readInput(String strInFile) { StringBuffer buffer = new StringBuffer(); try { FileInputStream fis = new FileInputStream(strInFile); InputStreamReader isr = new InputStreamReader(fis, "GB2312"); Reader in = new BufferedReader(isr); int ch; while ((ch = in.read()) > -1) { iCharNum += 1;buffer.append((char)ch); } in.close(); return buffer.toString(); } catch (IOException e) { e.printStackTrace(); return null; } } } |
| HashTable form=HttpUtils .parseQueryString(request.getQueryString())或者 form=HttpUtils.parsePostData(……) |
0
顶一下0
踩一下