codeblocks±àÂëÎÊÌâ
Òª½â¾öÕâ¸öÎÊÌ⣬ÏÈÒª¸ãÇå³þÓÐÈý¸öµØ·½Éæ¼°µ½±àÂëÎÊÌâ¡£
1.1 CodeBlocks ±à¼Æ÷±£´æÔ´ÎļþÓõıàÂë¡£
ĬÈÏÇé¿öÏ£¬ÊDZ£´æΪwindows±¾µØ±àÂëµÄ£¬Ò²¾ÍÊÇWINDOWS-936×Ö·û¼¯£¬Ò²¾ÍÊÇGBK±àÂë¡£
µ«ÊǺÜÉñÆæµÄÊÇ£¬GCC±àÒëÆ÷ĬÈϱàÒëµÄʱºòÊÇ°´ÕÕUTF-8½âÎöµÄ¡£Äã´æ³ÉGBK£¬µ«Êǵ±³ÉUTF-8½âÎö£¬Õ⻹ÄܱàÒëͨ¹ý£¬Õâ²ÅÓйíÁË£¬ËùÒÔÕâÁ½¸öµØ·½±àÂ벻ͳһºÃ£¬±àÒëµÄʱºò±¨´í£ºerror: converting to execution character set: Illegal byte sequence£¬Äã¸ù±¾Á¬Í¨¹ý±àÒëµÄ¿ÉÄÜÐÔ¶¼Ã»ÓУ¡
ÆäʵҪ½â¾öÕâ¸öÎÊÌâºÜ¼òµ¥£¬±àдCode£º£ºBlocksµÄÈËÖ»ÐèÒªÔÚµ÷ÓñàÒëÆ÷֮ǰ¼ì²âÒ»ÏÂÔ´ÎļþÊÇʲô±àÂ룬Ȼºó¾Í×Ô¶¯ÈñàÒëÆ÷ÓÃʲô±àÂë½øÐнâÊÍ£¬ÎÊÌâ¾Í½â¾öÁË¡£Ö»ÊǺܿÉϧ£¬Code::Blocks±àдµÄÈË¿ÉÄÜ»¹Ã»ÓÐÕâô×ö£¬»òÐíÊǶԱ¾µØ»¯ÈÏʶ²»¹»°É£¬Ò²¿ÉÄÜÊǾõµÃû±ØÒª°É£¿£¨ËùÒԾ͸ø³õѧµÄÈË´øÀ´ÎÊÌâÁË£¬ËùÒԾ;õµÃÒ×ÓÃÐÔ²»Èç΢ÈíÁË£¬Ãâ·ÑºÍÉÌÒµµÄ¶«Î÷»¹ÊÇÓвî¾àµÄ£©
1.2 GCC±àÒëÆ÷±àÒëµÄʱºò¶ÔÊäÈëµÄÔ´Îļþ½âÊÍÓõıàÂë
Õâ¸ö±àÒëÆ÷¿ÉÒÔÉèÖÃ-finput-charset=charsetÀ´Ö¸¶¨±àÒëÆ÷ÓÃʲô±àÂë½âÊÍÊäÈëÔ´Îļþ¡£±ÈÈçÈç¹ûÔ´ÎļþµÄ×Ö·û¼¯ÊÇGBk,ÄÇô¾Í±ØÐëÖ¸¶¨-finput-charset=GBK,Èç¹û²»Ö¸¶¨£¬Ò»Âɵ±×öUTF-8´¦Àí¡£
³ý·ÇÄãÔ´ÎļþÕæµÄÊÇUTF-8£¬·ñÔò¾Í»á³öÏÖת»»´íÎó¡£
1.3 ±àÒëºÃµÄÖ´ÐÐÎļþËùÓñàÂë
Èç¹ûÄã1ºÍ2Á½¸öµØ·½µÄ±àÂ붼ÄÜͳһ£¬ÄÇô±àÒëʱ²»»á±¨´íÁË£¬µ«ÊDZàÒëºÃÁË£¬ÔËÐÐһϿ´¿´£¬ÔÚ¿ØÖÆ̨ÏÔʾµÄÒÀÈ»ÊÇÂÒÂ룡
ÄÇÊÇÒòΪ¿ØÖÆ̨ÏÔʾµÄʱºòȱʡµÄÊÇʹÓÃϵͳĬÈϵÄ×Ö·û¼¯£¬±ÈÈçwindowsÏÂÓõÄÊÇGBk£¬µ«ÊÇĬÈÏÇé¿öÏ£¬±àÒëÖ®ºóµÄÖ´ÐÐÎļþʱ±àÒë³ÉUTF-8µÄ£¬ËùÒÔÓÖ³öÏÖÁ˲»Í³Ò»£¬ÂÒÂëÓɴ˶øÉú£¡
½â¾öµÄ·½·¨ºÍ¼òµ¥£¬¾ÍÊǸø±àÒëÆ÷¼ÓÉÏÑ¡Ï-fexec-charset=GBK£¬ºÍwindowsĬÈϵÄͳһ£¬¾ÍOKÁË¡£
¸ã¶®ÁËÂÒÂë²úÉúµÄÔÒò£¬ÄÇô²»Äѵóö½áÂÛ£¬ÈçºÎÐ޸ģ¬ÄãÏëÐ޸ijÉʲô¶¼OK£¬¹Ø¼üÊÇҪͳһ£¬²¢²»ÊÇÏñÍøÉÏһЩÈË˵µÄ£¬Ð޸ijÉGBK¾ÍOK£¬ÆäʵÄãÒªÐ޸ijÉUTF-8¶¼OK£¬¹Ø¼üÊÇͳһ¡£
1.4 Ð޸ĵĵط½¡£
1. ÐÞ¸ÄÔ´Îļþ±£´æ±àÂëÔÚ£ºsettings->Editor->gernal settings ÕÒµ½Encoding group Box
Use encoding when opening files:Õâ¸ö±íʾ´ò¿ªÎļþÓõĸñʽ£¬µÚÒ»´Î±£´æÎļþµÄʱºòÒ²»áÓÃÕâ¸ö¸ñʽ¡£
As default encoding:±íʾÉèÖÃΪÎļþȱʡ±£´æºÍ´ò¿ª±àÂë¸ñʽ
×¢Ò⣬ҪÏÈÉèÖúã¬È»ºó±£´æÎļþ£¬²ÅÓÐЧ¡£Èç¹ûÄãÒѾ±£´æÁËÎļþ£¬ÎÞÂÛÄãÔõôÐÞ¸ÄÕâ¸öÉèÖã¬Ò²²»»á¸Ä±äÄãÎļþµÄ¸ñʽÁË¡£ÄãµÄÎļþ»¹ÊDZ£³ÖµÚÒ»´Î±£´æµÄʱºòµÄ¸ñʽ¡£ËùÒÔ£¬Èç¹ûÓöµ½ÎÞ·¨ÉúЧ£¬Ö»ÄÜÏÈÉèÖúøñʽ£¬ÔÙÖØн¨ÎļþÁË¡£
2. Ð޸ıàÒëÆ÷¶ÔÔ´Îļþ½âÊͱàÂë¸ñʽºÍÉú³ÉÖ´ÐÐÎļþÖ´ÐÐʱºò²ÉÓõıàÂë¸ñʽÊÇÔÚsettings->compiler and debugger settingsÀïÃ棬ѡÔñ¶ÔÓ¦µÄGCC±àÒëÆ÷£¬ÈçÏÂͼËùʾ£º
ÔÚother optionsÀïÃæ¼ÓÈ룺
-finput-charset=charset
-fexec-charset=charset
µÚÒ»¸ö²ÎÊý±íʾ±àÒëµÄʱºòÊäÈëÎļþµÄ±àÂë½âÊ͸ñʽ£¬µÚ¶þ²ÎÊý±íʾÉú³ÉµÄÖ´ÐÐÎļþÖ´ÐеÄʱºòÏÔʾÓõıàÂë¸ñʽ¡£ÕâЩ²ÎÊýÈç¹ûºÍʵ¼Ê²»ÎǺϣ¬±ØÈ»²úÉúÂÒÂë¡£Ö»ÒªÎǺϣ¬¾Í²»»áÂÒÂëÁË¡£
ÓÉÓÚÎÒµÄÔ´Îļþ¸ñʽÊÇWINDOWS-936,µ«ÊÇÕâÀïÉèÖóÉUTF-8£¬ËùÒÔ±àÒë¿Ï¶¨±¨´í£¡
Ö»ÐèÒªÐ޸ijÉ-finput-charset=WINDOWS-936»òÕßGBk£¬¾Í±àÒëͨ¹ýÁË¡£
Èç¹û²»ÉèÖÃfexec-charsetĬÈÏ»áÈÏΪִÐл·¾³ÊÇUTF-8£¬¶øwindowsϲ¢²»ÊÇ£¬ËùÒÔLinuxÏÂûÎÊÌ⣬ÒòΪlinux¾ÍÊÇUTF-8µÄ£¬µ«ÊÇwindows ϱØÈ»³öÏÖÂÒÂë¡£ËùÒÔÉèÖóÉGBk£¬¾ÍͳһÁË¡£