Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

java ×Ö·û±àÂë

String newStr = new String(oldStr.getBytes(), "UTF-8");

javaÖеÄStringÀàÊÇ°´ÕÕunicode½øÐбàÂëµÄ£¬µ±Ê¹ÓÃString(byte[] bytes, String encoding)¹¹Ôì×Ö·û´®Ê±£¬encodingËùÖ¸µÄÊÇbytesÖеÄÊý¾ÝÊÇ°´ÕÕÄÇÖÖ·½Ê½±àÂëµÄ£¬¶ø²»ÊÇ×îºó²úÉúµÄStringÊÇʲô±àÂ뷽ʽ£¬»»¾ä»°Ëµ£¬ÊÇÈÃϵͳ°ÑbytesÖеÄÊý¾ÝÓÉencoding±àÂ뷽ʽת»»³Éunicode±àÂë¡£Èç¹û²»Ö¸Ã÷£¬bytesµÄ±àÂ뷽ʽ½«ÓÉjdk¸ù¾Ý²Ù×÷ϵͳ¾ö¶¨¡£

µ±ÎÒÃÇ´ÓÎļþÖжÁÊý¾Ýʱ£¬×îºÃʹÓÃInputStream·½Ê½£¬È»ºó²ÉÓÃString(byte[] bytes, String encoding)Ö¸Ã÷ÎļþµÄ±àÂ뷽ʽ¡£²»ÒªÊ¹ÓÃReader·½Ê½£¬ÒòΪReader·½Ê½»á×Ô¶¯¸ù¾ÝjdkÖ¸Ã÷µÄ±àÂ뷽ʽ°ÑÎļþÄÚÈÝת»»³Éunicode ±àÂë¡£

µ±ÎÒÃÇ´ÓÊý¾Ý¿âÖжÁÎı¾Êý¾Ýʱ£¬²ÉÓÃResultSet.getBytes()·½·¨È¡µÃ×Ö½ÚÊý×飬ͬÑù²ÉÓôø±àÂ뷽ʽµÄ×Ö·û´®¹¹Ôì·½·¨¼´¿É¡£

ResultSet rs;
bytep[] bytes = rs.getBytes();
String str = new String(bytes, "gb2312");

²»Òª²ÉÈ¡ÏÂÃæµÄ²½Öè¡£

ResultSet rs;
String str = rs.getString();
str = new String(str.getBytes("iso8859-1"), "gb2312");

ÕâÖÖ±àÂëת»»·½Ê½Ð§Âʵס£Ö®ËùÒÔÕâô×öµÄÔ­ÒòÊÇ£¬ResultSetÔÚgetString()·½·¨Ö´ÐÐʱ£¬Ä¬ÈÏÊý¾Ý¿âÀïµÄÊý¾Ý±àÂ뷽ʽΪ iso8859-1¡£ÏµÍ³»á°ÑÊý¾ÝÒÀÕÕiso8859-1µÄ±àÂ뷽ʽת»»³Éunicode¡£Ê¹ÓÃstr.getBytes("iso8859-1")°ÑÊý¾Ý»¹Ô­£¬È»ºóÀûÓÃnew String(bytes, "gb2312")°ÑÊý¾Ý´Ógb2312ת»»³Éunicode£¬Öмä¶àÁ˺öಽÖè¡£

´ÓHttpRequestÖжÁ²ÎÊýʱ£¬ÀûÓÃreqeust.setCharacterEncoding()·½·¨ÉèÖñàÂ뷽ʽ£¬¶Á³öµÄÄÚÈݾÍÊÇÕýÈ·µÄÁË¡£
ÏÈ˵Java¡£
JVMÀïÃæµÄÈκÎ×Ö·û´®×ÊÔ´¶¼ÊÇUnicode£¬¾ÍÊÇ˵£¬ÈκÎStringÀàÐ͵ÄÊý¾Ý¶¼ÊÇUnicode±àÂ롣ûÓÐÀýÍâ¡£¼ÈȻֻÓÐÒ»ÖÖ±àÂ룬ÄÇô£¬ÎÒÃÇ¿ÉÒÔÕâô˵£¬JVMÀïÃæµÄStringÊDz»´ø±àÂëµÄ¡£StringÏ൱ÓÚ char[]¡£
JVMÀïÃæµÄ byte[] Êý¾ÝÊÇ´ø±àÂëµÄ¡£±ÈÈ磬Big5£¬GBK£¬GB2312£¬UTF-8Ö®ÀàµÄ¡£
Ò»¸öGBK±àÂëµÄbyte[] ת»»³É String£¬Æäʵ¾ÍÊÇ´ÓGBK±àÂëÏòUnicode±àÂëת»»¡£
Ò»¸öStringת»»³ÉÒ»¸öBig5±àÂëµÄbyte[]£¬Æäʵ¾ÍÊÇ´ÓUnicode±àÂëÏòBig5±àÂëת»»¡£
ËùÒÔ£¬UnicodeÊÇËùÓбàÂëת»»µÄÖмä½éÖÊ¡£ËùÓеıàÂ붼ÓÐÒ»¸öת»»Æ÷¿ÉÒÔת»»µ½Unicode£¬¶øUnicodeÒ²¿ÉÒÔת»»µ½ÆäËûËùÓеıàÂë¡£Õâ


Ïà¹ØÎĵµ£º

java·´Éä»úÖÆ

JAVA·´Éä»úÖÆ
    JAVA·´Éä»úÖÆÊÇÔÚÔËÐÐ״̬ÖУ¬¶ÔÓÚÈÎÒâÒ»¸öÀ࣬¶¼Äܹ»ÖªµÀÕâ¸öÀàµÄËùÓÐÊôÐԺͷ½·¨£»¶ÔÓÚÈÎÒâÒ»¸ö¶ÔÏ󣬶¼Äܹ»µ÷ÓÃËüµÄÈÎÒâÒ»¸ö·½·¨£»ÕâÖÖ¶¯Ì¬»ñÈ¡µÄÐÅÏ¢ÒÔ¼°¶¯Ì¬µ÷ÓöÔÏóµÄ·½·¨µÄ¹¦ÄܳÆΪjavaÓïÑԵķ´Éä»úÖÆ¡£
Java·´Éä»úÖÆÖ÷ÒªÌṩÁËÒÔϹ¦ÄÜ£º ÔÚÔËÐÐʱÅжÏÈÎÒâÒ»¸ö¶ÔÏóËùÊô ......

Suse LinuxϵͳÏÂJAVA AWT½çÃæÂÒÂëÎÊÌâ

ÔÚSuse10.1Ï°²×°EOS5.3£¬½çÃæ°´Å¥·²ÖÐÎĶ¼ÊÇ·½¸ñ£¬¿ÉÔÚÖն˲鿴ÖÐÎĶ¼ÊǺõģ¬ÍøÉÏËÑÁ˺ü¸Ì죬ÖÕÓÚŪÃ÷°×Ô­Òò¡£
 
EOS5.3ʹÓõÄÊÇjdk1.4.2£¬ÔÚsuseÏÂûÓÐjdkĬÈÏÒªÇóµÄÖÐÎÄ×ÖÌ壬ÐèÒª×ö¶îÍâµÄÅäÖã¬Ð޸ķ½·¨ÈçÏ£º
 
1.ʹÓÃsuÃüÁîÇл»ÎªrootÓû§£¬ÔÙʹÓÃcdÃüÁîÇл»µ½jdk°²×°Â·¾¶ÏµÄjre£»ÀýÈ磺
  ......

javaÀàÖÐдsqlÓï¾ä£¬²éѯÌõ¼þ°üº¬»»ÐÐ

detachedCriteria.add(Restrictions.or(
       Restrictions.like("chengBanDanWeiIds", rForm.getChengBanDanWeiIds()+(char)13, MatchMode.START),
       Restrictions.or(
          &n ......

¼ÆËãJavaÈÕÆÚ£­£­Ñ§Ï°ÔõÑù´´½¨ºÍʹÓÃÈÕÆÚ


¸ÅÒª
²»¹ÜÄãÊÇ´¦Àí²ÆÎñ½»Ò×»¹ÊǼƻ®×ÅÏÂÒ»²½µÄÐж¯£¬Ä㶼Ҫ֪µÀÔõÑùÔÚJavaÖн¨Á¢£¬Ê¹ÓúÍÏÔʾÈÕÆÚ¡£ÕâÐèÒªÄã¼òµ¥µÄ²éÔÄÒ»ÏÂÏàÓ¦ÀàµÄAPI²Î¿¼£ºÒ»¸öÈÕÆÚ¿ÉÒÔ´´½¨3¸öÏà¹ØÀàµÄ¶ÔÏó¡£ÕâƪÎÄÕ¸æËßÄãÄãÏëÒªÖªµÀµÄÄÚÈÝ¡£
Javaͳ¼Æ´Ó1970Äê1ÔÂ1ÈÕÆðµÄºÁÃëµÄÊýÁ¿±íʾÈÕÆÚ¡£Ò²¾ÍÊÇ˵£¬ÀýÈ磬1970Äê1ÔÂ2ÈÕ£¬ÊÇÔÚ1ÔÂ1ÈÕºóµÄ86£¬400£ ......

java±àÂë2

String str = "ÖÐ";
 
 
  String str1 = new String(str.getBytes("gbk"), "ISO8859-1");
  String str2 = new String(str1.getBytes("ISO8859-1"), "gbk");
  System.out.println(str2);  //Êä³ö"ÖÐ" ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ