{"id":1969,"date":"2015-06-03T02:13:33","date_gmt":"2015-06-02T17:13:33","guid":{"rendered":"http:\/\/uda2.com\/blog\/?p=1969"},"modified":"2015-06-03T02:13:33","modified_gmt":"2015-06-02T17:13:33","slug":"mac_filename","status":"publish","type":"post","link":"https:\/\/uda2.com\/blog\/mac_filename\/","title":{"rendered":"mac\u306e\u6fc1\u70b9\u30fb\u534a\u6fc1\u70b9\u304c\u5206\u96e2\u3057\u305f\u3092\u30d5\u30a1\u30a4\u30eb\u540d\u4e00\u89a7\u3092\u878d\u5408"},"content":{"rendered":"<p>\u3055\u3066\u3001\u5f15\u304d\u7d9a\u304d\u691c\u7d22\u3059\u308b\u30d7\u30ed\u30b0\u30e9\u30e0\u306a\u3093\u3067\u3059\u304c\u3001\u305d\u3082\u305d\u3082Mac\u306b\u306f\u6a19\u6e96\u3067\u62e1\u5f35\u7248iconv\u304c\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u3066\u3044\u3066\u6fc1\u70b9\u30fb\u534a\u6fc1\u70b9\u304c\u5206\u96e2\u3057\u305f\u6587\u5b57\u3092\u878d\u5408\u3067\u304d\u308b\u3002<br \/>\n\u8a66\u3057\u306b\u30d5\u30a1\u30a4\u30eb\u4e00\u89a7\uff08hoge.txt\uff09\u3092\u4f5c\u3063\u3066\u3001iconv\uff08fuge.txt\uff09\u3067\u5909\u63db\u3057\u3066\u307f\u305f\u3002<br \/>\n<strong>$ find . >hoge.txt<\/strong><br \/>\n<strong>$ iconv -f UTF-8-MAC -t UTF-8 hoge.txt -o fuge.txt<\/strong><br \/>\n\u7d50\u679c\u306f\u9014\u4e2d\u3067\u6b62\u307e\u3063\u3066\u3057\u307e\u3046\u3002\u3069\u3046\u3084\u3089\u6587\u5b57\u6570\u5236\u9650\u304c\u3042\u308b\u3088\u3046\u3060\u3002<br \/>\n<!--more--><br \/>\n<a href=\"http:\/\/shokai.org\/blog\/archives\/6177\" target=\"_blank\">Ruby<\/a>\u3084<a href=\"http:\/\/qiita.com\/koduki\/items\/6080839f3e72f5fe99a5\" target=\"_blank\">Java<\/a>\u3067\u306f\u7c21\u5358\u306b\u3067\u304d\u308b\u3088\u3046\u3060\u304cMac\u306bRuby\u3092\u5165\u308c\u3066\u306a\u3044\u3057\u3001Ruby\u3082Java\u3082\u82e6\u624b\u3060\u3002<\/p>\n<p>NFD\u306e\u6fc1\u70b9\u30fb\u534a\u6fc1\u70b9\u3092\u5206\u96e2\u3057\u30661\u6587\u5b57\u3068\u3059\u308b\u65b9\u5f0f\u306fUTF-8-MAC\u3068\u8868\u8a18\u3055\u308c\u305f\u308a\u3059\u308b\u4e8b\u3082\u3042\u308b\u304c\u6587\u5b57\u30b3\u30fc\u30c9\u3067\u306f\u7121\u3044\u306e\u3067\u5358\u7d14\u306bPHP\u306emb_convert_encording\u3067\u306f\u5909\u63db\u51fa\u6765\u306a\u3044\u3002<br \/>\n\u305d\u3053\u3067\u81ea\u524d\u3067\u5909\u63db\u3059\u308b\u95a2\u6570\u3092\u4f5c\u3063\u305f\u3002\uff08\u601d\u3044\u3064\u304f\u9650\u308a\u306e\u6587\u5b57\u3092\u5165\u308c\u3066\u307e\u3059\u304c\u8db3\u308a\u306a\u3044\u6587\u5b57\u304c\u3042\u308b\u304b\u3082\u3057\u308c\u307e\u305b\u3093\uff09<\/p>\n<pre><code>function macDakuten($str){\r\n\t$daku = \"\\xE3\\x82\\x99\";\/\/http:\/\/www.fileformat.info\/info\/unicode\/char\/3099\/index.htm\r\n\tif (strpos($str,$daku) !== false) {\r\n\t\t$hiras = array(\"\u304b\" =&gt; \"\u304c\",\"\u304d\" =&gt; \"\u304e\",\"\u304f\" =&gt; \"\u3050\",\"\u3051\" =&gt; \"\u3052\",\"\u3053\" =&gt; \"\u3054\",\"\u3055\" =&gt; \"\u3056\",\"\u3057\" =&gt; \"\u3058\",\"\u3059\" =&gt; \"\u305a\",\"\u305b\" =&gt; \"\u305c\",\"\u305d\" =&gt; \"\u305e\",\"\u305f\" =&gt; \"\u3060\",\"\u3061\" =&gt; \"\u3062\",\"\u3064\" =&gt; \"\u3065\",\"\u3066\" =&gt; \"\u3067\",\"\u3068\" =&gt; \"\u3069\",\"\u306f\" =&gt; \"\u3070\",\"\u3072\" =&gt; \"\u3073\",\"\u3075\" =&gt; \"\u3076\",\"\u3078\" =&gt; \"\u3079\",\"\u307b\" =&gt; \"\u307c\",\"\u3046\" =&gt; \"\u30f4\");\r\n\t\t$katas = array(\"\u30ab\" =&gt; \"\u30ac\",\"\u30ad\" =&gt; \"\u30ae\",\"\u30af\" =&gt; \"\u30b0\",\"\u30b1\" =&gt; \"\u30b2\",\"\u30b3\" =&gt; \"\u30b4\",\"\u30b5\" =&gt; \"\u30b6\",\"\u30b7\" =&gt; \"\u30b8\",\"\u30b9\" =&gt; \"\u30ba\",\"\u30bb\" =&gt; \"\u30bc\",\"\u30bd\" =&gt; \"\u30be\",\"\u30bf\" =&gt; \"\u30c0\",\"\u30c1\" =&gt; \"\u30c2\",\"\u30c4\" =&gt; \"\u30c5\",\"\u30c6\" =&gt; \"\u30c7\",\"\u30c8\" =&gt; \"\u30c9\",\"\u30cf\" =&gt; \"\u30d0\",\"\u30d2\" =&gt; \"\u30d3\",\"\u30d5\" =&gt; \"\u30d6\",\"\u30d8\" =&gt; \"\u30d9\",\"\u30db\" =&gt; \"\u30dc\",\"\u30a6\" =&gt; \"\u30f4\");\r\n\t\tforeach($hiras as $mykey =&gt; $myvalue) { $str = str_replace($mykey.$daku,$myvalue,$str); }\r\n\t\tforeach($katas as $mykey =&gt; $myvalue) { $str = str_replace($mykey.$daku,$myvalue,$str); }\r\n\t}\r\n\t$daku = \"\\xE3\\x82\\x9A\";\/\/http:\/\/www.fileformat.info\/info\/unicode\/char\/309a\/index.htm\r\n\tif (strpos($str,$daku) !== false) {\r\n\t\t$hiras = array(\"\u306f\" =&gt; \"\u3071\",\"\u3072\" =&gt; \"\u3074\",\"\u3075\" =&gt; \"\u3077\",\"\u3078\" =&gt; \"\u307a\",\"\u307b\" =&gt; \"\u307d\");\r\n\t\t$katas = array(\"\u30cf\" =&gt; \"\u30d1\",\"\u30d2\" =&gt; \"\u30d4\",\"\u30d5\" =&gt; \"\u30d7\",\"\u30d8\" =&gt; \"\u30da\",\"\u30db\" =&gt; \"\u30dd\");\r\n\t\tforeach($hiras as $mykey =&gt; $myvalue) { $str = str_replace($mykey.$daku,$myvalue,$str); }\r\n\t\tforeach($katas as $mykey =&gt; $myvalue) { $str = str_replace($mykey.$daku,$myvalue,$str); }\r\n\t}\r\n\treturn $str;\r\n}<\/code><\/pre>\n<p>\u666e\u901a\u306b\u691c\u7d22\u3092\u3059\u308b\u306a\u3089UTF-8\u304b\u3089UTF-8-MAC\u306b\u5909\u63db\u3057\u3066\u691c\u7d22\u3059\u308b\u3079\u304d\u3067\u3059\u304c\u3001<br \/>\n\u4eca\u56de\u306fmac\u304c\u666e\u6bb5\u5bdd\u3066\u308b\u4e8b\u304b\u3089\u5168\u30d5\u30a1\u30a4\u30eb\u4e00\u89a7\u3092\u62bd\u51fa\u3057\u3001UTF-8-MAC\u2192UTF-8\u306e\u5909\u63db\u3057\u305f\u4e0a\u3067Dropbox\u5185\u306b\u4fdd\u5b58\u3059\u308b\u4e8b\u306b\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u30b9\u30de\u30fc\u30c8\u3067\u306f\u7121\u3044\u6c17\u3082\u3057\u307e\u3059\u304c\u3001\u6fc1\u70b9\u304c\u691c\u7d22\u51fa\u6765\u306a\u3044\u554f\u984c\u304c\u89e3\u6c7a\u3057\u3001\u4f55\u6642\u3067\u3082\u4f55\u51e6\u3067\u3082\u691c\u7d22\u53ef\u80fd\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3055\u3066\u3001\u5f15\u304d\u7d9a\u304d\u691c\u7d22\u3059\u308b\u30d7\u30ed\u30b0\u30e9\u30e0\u306a\u3093\u3067\u3059\u304c\u3001\u305d\u3082\u305d\u3082Mac\u306b\u306f\u6a19\u6e96\u3067\u62e1\u5f35\u7248iconv\u304c\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u3066\u3044\u3066\u6fc1\u70b9\u30fb\u534a\u6fc1\u70b9\u304c\u5206\u96e2\u3057\u305f\u6587\u5b57\u3092\u878d\u5408\u3067\u304d\u308b\u3002 \u8a66\u3057\u306b\u30d5\u30a1\u30a4\u30eb\u4e00\u89a7\uff08hoge.txt\uff09\u3092\u4f5c\u3063\u3066\u3001iconv\uff08fuge.<\/p>\n","protected":false},"author":2,"featured_media":1970,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[206],"tags":[301,304,303,302],"class_list":["post-1969","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-diary","tag-mac","tag-utf-8-mac","tag-303","tag-302"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/uda2.com\/blog\/wp-json\/wp\/v2\/posts\/1969","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/uda2.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/uda2.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/uda2.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/uda2.com\/blog\/wp-json\/wp\/v2\/comments?post=1969"}],"version-history":[{"count":4,"href":"https:\/\/uda2.com\/blog\/wp-json\/wp\/v2\/posts\/1969\/revisions"}],"predecessor-version":[{"id":1978,"href":"https:\/\/uda2.com\/blog\/wp-json\/wp\/v2\/posts\/1969\/revisions\/1978"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/uda2.com\/blog\/wp-json\/wp\/v2\/media\/1970"}],"wp:attachment":[{"href":"https:\/\/uda2.com\/blog\/wp-json\/wp\/v2\/media?parent=1969"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/uda2.com\/blog\/wp-json\/wp\/v2\/categories?post=1969"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/uda2.com\/blog\/wp-json\/wp\/v2\/tags?post=1969"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}