README.UNICODEã®è¦ç´
PHP6ãããã¤ãã£ãUnicodeãµãã¼ããå§ã¾ãããã§ãããå®ã®ã¨ãããã©ããããã®ãªã®ãããåãããªãã£ãããã¾ã;-)
ã§ãã½ã¼ã¹ã«ä»å±ããREADME.UNICODEï¼ãªãã¸ã§ã³1.8ï¼ãè¦ç´ãã¦ã¿ã¾ããã
ééããããã°ææããé¡ããã¾ãã
- å é¨ã¯UTF-16
- ICUãå©ç¨ãã
- ICUã§ãµãã¼ãããã¦ããã¨ã³ã³ã¼ãã£ã³ã°ãå©ç¨å¯è½
- æåãªãã©ã«ãHTTPãªã¯ã¨ã¹ããPHPèå¥åã¯å ¨ã¦Unicode
- unicode.semantics = On/Offã§Unicodeãµãã¼ããåãæ¿ãã
- Offã®å ´åãæåãªãã©ã«ã¯ãã¤ããªæ±ã
- fallback encodingãæå®ããªãå ´åãUTF-8ã¨ãªã
- unicode.runtime_encodingã§ãã¤ããªæååå¤æã®ã¨ã³ã³ã¼ãã£ã³ã°ãæå®
- ãã£ã¹ã
- åºåã¨ã³ã³ã¼ãã£ã³ã°ã¯unicode.output_encodingã§æå®
- ãã¤ããªæååã¯å¤æããªã
- ç¾ç¶ã®default_charsetã¯æ¨å¥¨ãããªããªãäºå®
- å ¥åã¨ã³ã³ã¼ãã£ã³ã°ã«ã¤ãã¦ã¯ç¾å¨éçºä¸
- ãã¡ã¤ã«ã·ã¹ãã ã¨ã³ã³ã¼ãã£ã³ã°ã¯unicode.filename_encodingã§æå®
- ãã¡ã¤ã«ã¨ã³ã³ã¼ãã£ã³ã°ããã£ã¬ã¯ããªå
- ã¹ã¯ãªããã¨ã³ã³ã¼ãã£ã³ã°ã¯unicode.script_encodingã§æå®
- ãã©ã°ãã使ã£ã¦iniè¨å®ãä¸æ¸ãå¯è½ï¼ãã¡ã¤ã«ã®å é ã§æå®ï¼
<?php declare(encoding = 'Shift-JIS');
-
- includeãããã¡ã¤ã«ã«ã¯å½±é¿ããªãäºã«æ³¨æ
- unicode.semanticsãOnã®å ´åãiniãã¡ã¤ã«ã¯utf-8ã¨ãã¦æ±ããã
- Offã®å ´åã¯PHP5ã¨åæ§ãas-isã
- ã¹ããªã¼ã I/O
- ããã©ã«ãã¯ãã¤ããªã¢ã¼ã
- ãtãã§ããã¹ãã¢ã¼ãã¨ãªããããã©ã«ãã¨ã³ã³ã¼ãã£ã³ã°ã¯UTF-8
<?php // UTF-8ã§èªã¿è¾¼ã¿ $fp = fopen('file.txt', 'rt'); $str = fread($fp, 100) // UTF-8ã§æ¸ã込㿠$fp = fopen('file.txt', 'wt'); $fwrite($fp, $uni)
-
- stream_default_encodingé¢æ°ã§ã¨ã³ã³ã¼ãã£ã³ã°ãæå®å¯è½
<?php stream_default_encoding('Shift-JIS'); $data = file_get_contents('file.txt', FILE_TEXT); // work on $data file_put_contents('file.txt', $data, FILE_TEXT);
-
-
- file_get_contentsã§FILE_TEXTãæå®ããå ´åã¯Unicodeæååãè¿ããã
- file_get_contentsã§FILE_TEXTãæå®ããªãå ´åã¯ãã¤ããªæååãè¿ããã
- ããã§ãè¯ã
-
<?php $ctx = stream_context_create(NULL, array('encoding' => 'big5')); $data = file_get_contents('file.txt', FILE_TEXT, $ctx); // work on $data file_put_contents('file.txt', $data, FILE_TEXT, $ctx);
- Unicodeå¤æã«å¤±æããå ´åãwarningãçºçãã
- unicode_set_error_handleré¢æ°ã§ã¨ã©ã¼ãã³ãã©ãä½æããæåãå¤ãããã¨ãå¯è½
- Unicodeæåååã¨ãã¤ããªæååå
- ãã¤ããªæåååã¯å¾æ¹äºææ§ãéUnicodeæååããã¤ããªãã¼ã¿ãæ±ããã
- ãã¤ããªæååã¯ã以ä¸ã®ããã«æ¸ãã
<?php $var = b'abc\001'; $var = b"abc\001"; $var = b<<<EOD abc\001 EOD;
- é åãããããåãã®ã§ã¯ãªããTextIteratorã使ã
<?php // \u308ã¯ã¦ã ã©ã¦ã // 6æå $text = "nai\u308ve"; foreach (new TextIterator($text) as $u) { var_inspect($u) } // 5æå $text = "nai\u308ve"; foreach (new TextIterator($text, TextIterator::CHARACTER) as $u) { var_inspect($u) }
- POSIXãã±ã¼ã«ã§ã¯ãªãICUãã±ã¼ã«ã«ãªãã®ã§ãsetlocaleé¢æ°ã使ããªããã¨
- 代ããã«ãlocale_set_defaulté¢æ°ãlocale_get_defaulté¢æ°ã使ç¨ãã