äºéã¨ã³ã³ã¼ãã®è©±ã«ã¤ãã¦ã®è£è¶³
AJITOã§é ã飲ã¿ãªããid:nTeTsã¨æ¨æ¥æ¸ããè¨äºã«ã¤ãã¦ããã¹ã£ã¦ãã¦ãid:nTeTsããã®åé¡ãPerlæååã®å é¨è¡¨ç¾ãUTF8ãã©ã°ã«é¢ããåé¡ã¨èªèãã¦ããç¯ããã£ããããã¯åã«ééã£ã¦ãã¦ããã®åé¡ã¯Perlåºæã§ã¯ãªããPerlæååã®å é¨è¡¨ç¾ãªã©ã¯ä¸åé¢ä¿ãªãã®ã ããã¾ãæ··ä¹±ãã¦ãç¡çã¯ãªãã¨ãæãã®ã§ãã®è¾ºã«ã¤ãã¦è£è¶³ãã¦ã¿ããããªãåã¯Perl5.8ããPerlã使ãå§ããã®ã§ãæ¬å½ã®æ´å²çãªçµç·¯ãªã©ã¯ç¥ããªããç¾ç¶ã®ä»æ§ãããªãã¼ã¹ã¨ã³ã¸ãã¢ãªã³ã°ãã¦æ´å²ççµç·¯ãæ¨æ¸¬ããã«ãããªãã®ã§ã誤ããå«ã¾ããå¯è½æ§ã¯ææãã¦ããã
Encode::encodeã¨Encode::decodeã®ã·ã°ããã£ãä»®æ³çã«åä»ãã§è¡¨ç¾ããã¨ããããçæ³çã«ã¯æ¬¡ã®ããã«ãªã£ã¦ããã¹ãã§ããã
//decodeã¯ãã¤ããª(:byte[])ããå é¨è¡¨ç¾(:String)ã¸ã®åå String decode(Encoding enc, byte[] src); //encodeã¯å é¨è¡¨ç¾(:String)ãããã¤ããª(:byte[])ã¸ã®åå byte[] encode(Encoding enc, String src);
ã ããããããå
¥ãå£ã§decodeã(byteããStringãå¾ã¦)ãããã°ã©ã ã§ã¯String(å
é¨è¡¨ç¾æåå)ã使ããåºå£ã§encodeãã(byteãåºåãã)ãã¨ãªãããã ã
ããåãå³ãããã§ãã¯ããè¨èªã§ããã°ãäºéã¨ã³ã³ã¼ãã¯åã«ã³ã³ãã¤ã©ã«ã·ã°ããã£ã®ä¸ä¸è´ã§ã¯ããããã®ã§åé¡ã¯é¡å¨åãã«ããã£ãã ããã
String text = "unk"; //ã³ã³ãã¤ã«ã¨ã©ã¼ï¼ Stringãæå¾ ãã¦ããã®ã«byte[]ã渡ããã byte[] fuck = encode(UTF8, encode(UTF8, text));
å®éã®Perlã®Encode::encodeã¯Stringã ãã§ã¯ãªãbyte[]ãåãåããäºéã¨ã³ã³ã¼ãã容æã«çã¿åºããããã¯è¨è¨ãã¹ã§ã¯ãªãå¾æ¹äºææ§ã®ããã®ä»æ§ã§ããã
- Perl5.6ã¾ã§ã¯byte[]ã®ãããªãã®ã¨ãã¦æååã表ç¾ããã¦ãã
- ãã®ä»æ§ã«åºã¥ãã¦æ¸ãããè¨å¤§ãªCPANã¢ã¸ã¥ã¼ã«ãåå¨ãã
- ãããPerl5.8ã§UNICODEããã¤ãã£ãã«ãµãã¼ããã
- éå»ã®è³ç£ã¯ãã¹ã¦ãã®ã¾ã¾åããã¨
ã¨ããã®ãEncodeã«èª²ãããã使å½ã ã£ãã¨æãããããã®ããã«latin-1ã¨ãã«ããã¤ããã¤ããªã®æååçµåã«éãã¦ã®å¥å¦ãªä»æ§ã¨ããEncode::encodeãflagged UTF8æåå以å¤ã¯åã«åãä»ããªãã¨ããä»æ§ã§ã¯ãªããã¨ãã£ããã¶ã¤ã³ããªãããã®ã ããã
ããã¯é£ããåé¡ãªã®ã§ãåç´ãªè§£æ±ºæ¹æ³ã¯ãªããã³ã¹ãã®æ¯æãã®ä¸é¨ã¯ãPerl5.8以éã«æ°ãã«å¤è¨èªãµãã¼ãããããã°ã©ã ãæ¸ãããã°ã©ãã«å§ããããããããããã¯ãããå¾ãªããã¨ã§ãããããã§ã¯ãªãã¦éå»ã®è³ç£ãæ¸ããè ã«ãã®æ¯æããæ±ãã¦ãããããããã¯éå»ã®è³ç£ã¨æ絶ããæ°ããä¸çãæ°ãã«ä½ã£ã¦ãããããããã誰ãã¤ãã¦ããªãã£ãã¨æãã(ANSI Cã«ã¯wchar_tã¨ãããã«ããã¤ãæåãåãæ±ãåãåå¨ããããWindowsçé以å¤ã§ã³ã¬ã使ã£ã¦ãã®ãæ» å¤ã«è¦ãªãã)
ã§ãPerlã§ã¯æ´å²çãªçµç·¯ã«ããäºéã¨ã³ã³ã¼ããçºçããããã®ã§ã¯ããããåé¡ã¯Perlåºæã§ã¯ãªããå¤é¨ããå ¥åããããã¼ã¿ãäºéã¨ã³ã³ã¼ãããã¦ããããçµå±ä»ã®æ¹æ³ã§ãã«ããã¤ãæååãå¦çããããã°ã©ã è¨èªã§ãã£ã¦ããªãããã®å¯¾å¿ãããªããã°ãªããªãã®ã ããã