{"id":51,"date":"2009-07-30T10:26:00","date_gmt":"2009-07-30T02:26:00","guid":{"rendered":"http:\/\/j178.mtgbb.com\/236"},"modified":"2011-02-28T22:54:18","modified_gmt":"2011-02-28T14:54:18","slug":"%e5%8f%96%e5%be%97utf8%e7%b7%a8%e7%a2%bc%e7%9a%84%e5%ad%97%e4%b8%b2%e9%95%b7%e5%ba%a6","status":"publish","type":"post","link":"https:\/\/j178.mtgbb.com\/?p=51","title":{"rendered":"\u53d6\u5f97UTF8\u7de8\u78bc\u7684\u5b57\u4e32\u9577\u5ea6"},"content":{"rendered":"<p>\/*<br \/>\n* \u7528\u65bcUTF8\u7de8\u78bc\u7684\u7a0b\u5e8f<br \/>\n* \u7372\u5f97\u5b57\u7b26\u4e32\u7684\u9577\u5ea6\uff0c\u4e00\u500b\u4e2d\u6587\u8868\u793a3\u500b\u9577\u5ea6<br \/>\n* itlearner\u8a3b\u91cb<br \/>\n*\/<\/p>\n<pre lang=\"php\" line=\"1\">\r\nfunction utf8_strlen($str) {\r\n$count = 0;\r\nfor($i = 0; $i < strlen($str); $i++){\r\n$value = ord($str[$i]);\r\nif($value > 127) {\r\n$count++;\r\nif($value >= 192 && $value <= 223) $i++;\r\nelseif($value >= 224 && $value <= 239) $i = $i + 2;\r\nelseif($value >= 240 && $value <= 247) $i = $i + 3;\r\nelse die('Not a UTF-8 compatible string');\r\n}\r\n$count++;\r\n}\r\nreturn $count;\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\/* * \u7528\u65bcUTF8\u7de8\u78bc\u7684\u7a0b\u5e8f * \u7372\u5f97\u5b57\u7b26\u4e32\u7684\u9577\u5ea6\uff0c\u4e00\u500b\u4e2d\u6587\u8868\u793a3\u500b\u9577\u5ea6 * itlearner\u8a3b\u91cb *\/ &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14],"tags":[56],"class_list":["post-51","post","type-post","status-publish","format-standard","hentry","category-php","tag-php"],"_links":{"self":[{"href":"https:\/\/j178.mtgbb.com\/index.php?rest_route=\/wp\/v2\/posts\/51","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/j178.mtgbb.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/j178.mtgbb.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/j178.mtgbb.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/j178.mtgbb.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=51"}],"version-history":[{"count":0,"href":"https:\/\/j178.mtgbb.com\/index.php?rest_route=\/wp\/v2\/posts\/51\/revisions"}],"wp:attachment":[{"href":"https:\/\/j178.mtgbb.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=51"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/j178.mtgbb.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=51"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/j178.mtgbb.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=51"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}