Java±à³Ì¼¼ÊõÖкº×ÖÎÊÌâµÄ·ÖÎö¼°½â¾ö
ÔÚ»ùÓÚ Java ÓïÑԵıà³ÌÖУ¬ÎÒÃǾ³£Åöµ½ºº×ֵĴ¦Àí¼°ÏÔʾµÄÎÊÌâ¡£Ò»´ó¶Ñ¿´²»¶®µÄÂÒÂë¿Ï¶¨²»ÊÇÎÒÃÇÔ¸Òâ¿´µ½µÄÏÔʾЧ¹û£¬ÔõÑù²ÅÄܹ»ÈÃÄÇЩºº×ÖÕýÈ·ÏÔʾÄØ£¿JavaÓïÑÔĬÈϵıàÂ뷽ʽÊÇUNICODE£¬¶øÎÒÃÇÖйúÈËͨ³£Ê¹ÓõÄÎļþºÍÊý¾Ý¿â¶¼ÊÇ»ùÓÚGB2312»òÕßBIG5µÈ·½Ê½±àÂëµÄ£¬ÔõÑù²ÅÄܹ»Ç¡µ±µØÑ¡Ôñºº×Ö±àÂ뷽ʽ²¢ÕýÈ·µØ´¦Àíºº×ֵıàÂëÄØ£¿±¾ÎĽ«´Óºº×Ö±àÂëµÄ³£Ê¶ÈëÊÖ£¬½áºÏJava±à³ÌʵÀý£¬·ÖÎöÒÔÉÏÁ½¸öÎÊÌâ²¢Ìá³ö½â¾öËüÃǵķ½°¸¡£
¡¡¡¡ÏÖÔÚ Java ±à³ÌÓïÑÔÒѾ¹ã·ºÓ¦ÓÃÓÚ»¥ÁªÍøÊÀ½ç£¬ÔçÔÚ Sun ¹«Ë¾¿ª·¢ Java ÓïÑÔµÄʱºò£¬¾ÍÒѾ¿¼Âǵ½¶Ô·ÇÓ¢ÎÄ×Ö·ûµÄÖ§³ÖÁË¡£Sun ¹«Ë¾¹«²¼µÄ Java ÔËÐл·¾³£¨JRE£©±¾Éí¾Í·ÖÓ¢ÎÄ°æºÍ¹ú¼Ê°æ£¬µ«Ö»Óйú¼Ê°æ²ÅÖ§³Ö·ÇÓ¢ÎÄ×Ö·û¡£²»¹ýÔÚ Java ±à³ÌÓïÑÔµÄÓ¦ÓÃÖУ¬¶ÔÖÐÎÄ×Ö·ûµÄÖ§³Ö²¢·ÇÈçͬ Java Soft µÄ±ê×¼¹æ·¶ÖÐËùÐû³ÆµÄÄÇÑùÍêÃÀ£¬ÒòΪÖÐÎÄ×Ö·û¼¯²»Ö»Ò»¸ö£¬¶øÇÒ²»Í¬µÄ²Ù×÷ϵͳ¶ÔÖÐÎÄ×Ö·ûµÄÖ§³ÖÒ²²»¾¡Ïàͬ£¬ËùÒÔ»áÓÐÐí¶àºÍºº×Ö±àÂë´¦ÀíÓйصÄÎÊÌâÔÚÎÒÃǽøÐÐÓ¦Óÿª·¢ÖÐÀ§ÈÅ×ÅÎÒÃÇ¡£Óкܶà¹ØÓÚÕâЩÎÊÌâµÄ½â´ð£¬µ«¶¼±È½ÏËöË飬²¢²»Äܹ»Âú×ã´ó¼ÒÆÈÇнâ¾öÎÊÌâµÄÔ¸Íû£¬¹ØÓÚ Java ÖÐÎÄÎÊÌâµÄϵͳÑо¿²¢²»¶à£¬±¾ÎÄ´Óºº×Ö±àÂ볣ʶ³ö·¢£¬·ÖÎö Java ÖÐÎÄÎÊÌ⣬ϣÍû¶Ô´ó¼Ò½â¾öÕâ¸öÎÊÌâÓÐËù°ïÖú¡£
ºº×Ö±àÂëµÄ³£Ê¶
¡¡¡¡ÎÒÃÇÖªµÀ£¬Ó¢ÎÄ×Ö·ûÒ»°ãÊÇÒÔÒ»¸ö×Ö½ÚÀ´±íʾµÄ£¬×î³£ÓõıàÂë·½·¨ÊÇ ASCII ¡£µ«Ò»¸ö×Ö½Ú×î¶àÖ»ÄÜÇø·Ö256¸ö×Ö·û£¬¶øºº×Ö³ÉǧÉÏÍò£¬ËùÒÔÏÖÔÚ¶¼ÒÔË«×Ö½ÚÀ´±íʾºº×Ö£¬ÎªÁËÄܹ»ÓëÓ¢ÎÄ×Ö·û·Ö¿ª£¬Ã¿¸ö×Ö½ÚµÄ×î¸ßλһ¶¨Îª1£¬ÕâÑùË«×Ö½Ú×î¶à¿ÉÒÔ±íʾ64K¸ñ×Ö·û¡£ÎÒÃǾ³£Åöµ½µÄ±àÂ뷽ʽÓÐ GB2312¡¢BIG5¡¢UNICODE µÈ¡£¹ØÓÚ¾ßÌå±àÂ뷽ʽµÄÏêϸ×ÊÁÏ£¬ÓÐÐËȤµÄ¶ÁÕß¿ÉÒÔ²éÔÄÏà¹Ø×ÊÁÏ¡£ÎÒ·ôdz̸һϺÍÎÒÃǹØϵÃÜÇÐµÄ GB2312 ºÍ UNICODE¡£GB2312 Â룬ÖлªÈËÃñ¹²ºÍ¹ú¹ú¼Ò±ê×¼ºº×ÖÐÅÏ¢½»»»ÓñàÂ룬ÊÇÒ»¸öÓÉÖлªÈËÃñ¹²ºÍ¹ú¹ú¼Ò±ê×¼×ַܾ¢²¼µÄ¹ØÓÚ¼ò»¯ºº×ֵıàÂ룬ͨÐÐÓÚÖйú´ó½µØÇø¼°Ð¼ÓÆ£¬¼ò³Æ¹ú±êÂë¡£Á½¸ö×Ö½ÚÖУ¬µÚÒ»¸ö×Ö½Ú£¨¸ß×Ö½Ú£©µÄֵΪÇøºÅÖµ¼Ó32£¨20H£©£¬µÚ¶þ¸ö×Ö½Ú£¨µÍ×Ö½Ú£©µÄֵΪλºÅÖµ¼Ó32£¨20H£©£¬ÓÃÕâÁ½¸öÖµÀ´±íʾһ¸öºº×ֵıàÂë¡£UNICODE ÂëÊÇ΢ÈíÌá³öµÄ½â¾ö¶à¹ú×Ö·ûÎÊÌâµÄ¶à×ֽڵȳ¤±àÂ룬Ëü¶ÔÓ¢ÎÄ×Ö·û²ÉÈ¡Ç°Ãæ¼Ó¡°0¡±×ֽڵIJßÂÔʵÏֵȳ¤¼æÈÝ¡£Èç ¡°A¡± µÄ ASCII ÂëΪ0x41£¬UNICODE ¾ÍΪ0x00£¬0x41¡£ÀûÓÃÌØÊâµÄ¹¤¾ß¸÷ÖÖ±àÂëÖ®¼ä¿ÉÒÔ»¥Ïàת»»¡£
¡¡¡¡Java ÖÐÎÄÎÊÌâµÄ³õ²½ÈÏʶ
¡¡¡¡ÎÒÃÇ»ùÓÚ Java ±à³ÌÓïÑÔ½øÐÐÓ¦Óÿª·¢Ê±£¬²»¿É±ÜÃâµØÒª´¦ÀíÖÐÎÄ¡£Java ±à³ÌÓïÑÔĬÈϵıàÂ뷽ʽÊÇ UNICODE£¬¶øÎÒÃÇͨ³£Ê¹ÓõÄÊý¾Ý¿â¼°Îļþ¶¼ÊÇ»ùÓÚ GB2312 ±àÂëµÄ£¬ÎÒÃǾ³£Åöµ½ÕâÑùµÄÇé¿ö£ºä¯ÀÀ»ùÓÚ JSP ¼¼ÊõµÄÍøÕ¾¿´µ½µÄÊÇÂÒÂ룬Îļþ´ò¿ªºó¿´µ½µÄÒ²ÊÇÂÒÂ룬±» Java Ð޸ĹýµÄÊý¾Ý¿âµÄÄÚÈÝÔÚ±ðµÄ³¡ºÏÓ¦ÓÃʱÎÞ·¨¼ÌÐøÕýÈ·µØÌṩÐÅÏ¢¡£
String sEnglish = ¡°apple¡±; String sChinese = ¡°Æ»¹û¡±; String s = ¡°Æ»¹û apple ¡±;
¡¡¡¡sEnglish µÄ³¤¶ÈÊÇ5£¬sChineseµÄ³¤¶ÈÊÇ4£¬¶ø s ĬÈϵij¤¶ÈÊÇ14¡£¶ÔÓÚ sEnglishÀ´Ëµ£¬ Java Öеĸ÷¸öÀ඼֧³ÖµÃ·Ç³£ºÃ£¬¿Ï¶¨Äܹ»ÕýÈ·ÏÔʾ¡£µ«¶ÔÓÚ sChinese ºÍ s À´Ëµ£¬ËäÈ» Java Soft ÉùÃ÷ Java µÄ»ù±¾ÀàÒѾ¿¼Âǵ½¶Ô¶à¹ú×Ö·ûµÄÖ§³Ö£¨Ä¬ÈÏ UNICODE ±àÂ룩£¬µ«ÊÇÈç¹û²Ù×÷ϵͳµÄĬÈϱàÂë²»ÊÇ UNICODE £¬¶øÊǹú±êÂëµÈ¡£´Ó Java Ô´´úÂëµ½µÃµ½ÕýÈ·µÄ½á¹û£¬Òª¾¹ý ¡°Java Ô´´úÂë-> Java ×Ö½ÚÂë-> ;ÐéÄâ»ú->²Ù×÷ϵͳ->ÏÔʾÉ豸¡±µÄ¹ý³Ì¡£ÔÚÉÏÊö¹ý³ÌÖеÄÿһ²½Ö裬ÎÒÃǶ¼±ØÐëÕýÈ·µØ´¦Àíºº×ֵıàÂ룬²ÅÄܹ»Ê¹×îÖÕµÄÏÔʾ½á¹ûÕýÈ·¡£
¡¡¡¡¡° Java Ô´´úÂë-> Java ×Ö½ÚÂ롱£¬±ê×¼µÄ Java ±àÒëÆ÷ javac ʹÓõÄ×Ö·û¼¯ÊÇϵͳĬÈϵÄ×Ö·û¼¯£¬±ÈÈçÔÚÖÐÎÄ Windows ²Ù×÷ϵͳÉϾÍÊÇ GBK ,¶øÔÚ Linux ²Ù×÷ϵͳÉϾÍÊÇISO-8859-1£¬ËùÒÔ´ó¼Ò»á·¢ÏÖÔÚ Linux ²Ù×÷ϵͳÉϱàÒëµÄÀàÖÐÔ´ÎļþÖеÄÖÐÎÄ×Ö·û¶¼³öÁËÎÊÌ⣬½â¾öµÄ°ì·¨¾ÍÊÇÔÚ±àÒëµÄʱºòÌí¼Ó encoding ²ÎÊý£¬ÕâÑù²ÅÄܹ»Óëƽ̨Î޹ء£Ó÷¨ÊÇ
¡¡¡¡javac ?Cencoding GBK¡£
¡¡¡¡¡° Java ×Ö½ÚÂë->ÐéÄâ»ú->²Ù×÷ϵͳ¡±£¬ Java ÔËÐл·¾³ £¨JRE£© ·ÖÓ¢ÎÄ°æºÍ¹ú¼Ê°æ£¬µ«Ö»Óйú¼Ê°æ²ÅÖ§³Ö·ÇÓ¢ÎÄ×Ö·û¡£ Java ¿ª·¢¹¤¾ß°ü £¨JDK£© ¿Ï¶¨Ö§³Ö¶à¹ú×Ö·û£¬µ«²¢·ÇËùÓеļÆËã»úÓû§¶¼°²×°ÁË JDK ¡£ºÜ¶à²Ù×÷ϵͳ¼°Ó¦ÓÃÈí¼þΪÁËÄܹ»¸üºÃµÄÖ§³Ö Java £¬¶¼ÄÚǶÁË JRE µÄ¹ú¼Ê°æ±¾£¬Îª×Ô¼ºÖ§³Ö¶à¹ú×Ö·ûÌṩÁË·½±ã¡£
¡¡¡¡¡°²Ù×÷ϵͳ->ÏÔʾÉ豸¡±£¬¶ÔÓÚºº×ÖÀ´Ëµ£¬²Ù×÷ϵͳ±ØÐëÖ§³Ö²¢Äܹ»ÏÔʾËü¡£Ó¢ÎIJÙ×÷ϵͳÈç¹û²»´îÅäÌØÊâµÄÓ¦ÓÃÈí¼þµÄ»°£¬Êǿ϶¨²»Äܹ»ÏÔʾÖÐÎĵġ£
¡¡¡¡»¹ÓÐÒ»¸öÎÊÌ⣬¾ÍÊÇÔÚ Java ±à³Ì¹ý³ÌÖУ¬¶ÔÖÐÎÄ×Ö·û½øÐÐÕýÈ·µÄ±àÂëת»»¡£ÀýÈ磬ÏòÍøÒ³Êä³öÖÐÎÄ×Ö·û´®µÄʱºò£¬²»ÂÛÄãÊÇÓÃ
out.println(string);
¡¡¡¡»¹ÊÇÓÃ<%=string%>£¬¶¼±ØÐë×÷ UNICODE µ½ GBK µÄת»»£¬»òÕßÊÖ¶¯£¬»òÕß×Ô¶¯¡£ÔÚ JSP 1.0ÖУ¬¿ÉÒÔ¶¨ÒåÊä³ö×Ö·û¼¯£¬´Ó¶øʵÏÖÄÚÂëµÄ×Ô¶¯×ª»»¡£Ó÷¨ÊÇ
<%@page contentType=¡±text/html;charset=gb2312¡± %>
¡¡¡¡µ«ÊÇÔÚһЩ JSP °æ±¾Öв¢Ã»ÓÐÌṩ¶ÔÊä³ö×Ö·û¼¯µÄÖ§³Ö£¬£¨ÀýÈç JSP 0.92£©£¬Õâ¾ÍÐèÒªÊÖ¶¯±àÂëÊä³öÁË£¬·½·¨·Ç³£¶à¡£×î³£Óõķ½·¨ÊÇ
String s1 = request.getParameter(¡°keyword¡±); String s2 = new String(s1.getBytes(¡°ISO-8859-1¡±),¡±GBK¡±);
ÍƼöÐÅÏ¢
- ÔÝÎ޼Ǽ
ÈÈÃÅÐÅÏ¢
- nohup: redirecting stderr to stdou....
- ʹÓÃlog_formatΪNginx·þÎñÆ÷ÉèÖøüÏêϸµÄÈÕÖ¾¸ñʽ
- jquery easyUI--dataGrid-Json
- [Ô´´]·ÂGoogle Reader¡¢ÐÂÀË΢²©¡¢ÌÚѶ΢²©µ....
- ÀûÓÃKeepalived+mysql¹¹½¨¸ß¿ÉÓÃMySQLË«Ö÷×Ô¶....
- Nginx+keepalivedʵÏÖ¸ºÔؾùºâºÍË«»úÈȱ¸¸ß¿ÉÓÃ
- jqueryʵÏÖÒ³Ãæ¼ÓÔؽø¶ÈÌõ
- Rolling cURL: PHP²¢·¢×î¼Ñʵ¼ù
- codeigniter ·ÓÉÖÕ¼«ÓÅ»¯(url rewrite)
- linuxÏÂÉèÖÃsshÎÞÃÜÂëµÇ¼
×î½ü¸üÐÂ
- java urlÖØд¼¼Êõ(UrlReWriter)
- [ת]JavaµÄÊý×飨Array£©¡¢Vector¡¢ArrayLis....
- jsp»·¾³ÏÂajaxÂÒÂëÎÊÌâµÄ½â¾ö
- JSP¼¼Êõ Ö¸Áî ÂÒÂëÎÊÌâ ÔËÐÐÔÀíºÍ¾Å´óÒþʽ¶ÔÏó web¿ª·¢µÄË....
- JAVA ˮӡ ͼƬ ÎÄ×Ö
- java¶þ½øÖÆ£¬ÔÂë¡¢·´Âë¡¢²¹Â롢λÔËËã
- Java WebÓ¦ÓÃÆô¶¯¼ä¸ôÖ´ÐеijÌÐò
- jspÉú³ÉxmlÎļþʾÀý
- javaÖÐÀà±äÁ¿¡¢Àà·½·¨¡¢ÊµÀý±äÁ¿¡¢ÊµÀý·½·¨
- JSPÒ³ÃæµÄÎåÖÖÌøת·½·¨
ÆÀÂÛ