{"id":1143,"date":"2019-03-13T14:39:12","date_gmt":"2019-03-13T05:39:12","guid":{"rendered":"https:\/\/qol-kk.com\/wp2\/?p=1143"},"modified":"2019-03-18T15:04:15","modified_gmt":"2019-03-18T06:04:15","slug":"post-1143","status":"publish","type":"post","link":"https:\/\/qol-kk.com\/wp2\/blog\/2019\/03\/13\/post-1143\/","title":{"rendered":"Laravel\uff1amb_convert_encoding \u304c\u539f\u56e0\u3067\u30a8\u30e9\u30fc\u767a\u751f"},"content":{"rendered":"<h2>Laravel\uff1amb_convert_encoding \u304c\u539f\u56e0\u3067\u30a8\u30e9\u30fc\u767a\u751f<\/h2>\n<p>\u65e7\u30b7\u30b9\u30c6\u30e0\u3067\u306f\u52d5\u3044\u3066\u3044\u305f\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u79fb\u690d(\u591a\u5c11\u4fee\u6b63)\u3057\u305f\u7d50\u679c\u3001\u30a8\u30e9\u30fc\u767a\u751f\u3002<\/p>\n<pre class=\"lang:default decode:true\">$check_title = mb_convert_encoding($sResponce,\"UTF-8\" ,\"auto\");\r\n\/\/\u5b9f\u884c\u7d50\u679c\r\nmb_convert_encoding(): Unable to detect character encoding<\/pre>\n<p>\u306a\u308b\u307b\u3069\u3001\u30a8\u30f3\u30b3\u30fc\u30c9\u304c\u89e3\u3089\u3093\u305e\u3068\u8a00\u3046\u4e8b\u3067\u3059\u306d\u3002<\/p>\n<h3>\u4f55\u3092\u3057\u305f\u304b\u3063\u305f\u304b<\/h3>\n<p>Amazon\u306a\u3069\u306e\u30b5\u30a4\u30c8\u304b\u3089\u5546\u54c1\u753b\u50cf\u3092\u53d6\u5f97\u3057\u3088\u3046\u3068\u8a66\u307f\u305f\u30b9\u30af\u30ea\u30d7\u30c8\u3067\u3059\u3002<\/p>\n<p>\u30ea\u30f3\u30af\u5207\u308c\u3084\u8aa4\u8a18\u8f09\u3067404\u30a8\u30e9\u30fc\u5c02\u7528\u30da\u30fc\u30b8\u3068\u304b\u306b\u98db\u3070\u3055\u308c\u305f\u6642\u306e\u51e6\u7406\u3092\u66f8\u3053\u3046\u3068\u4e0a\u8a18\u30b3\u30fc\u30c9\u3092\u66f8\u3044\u3066\u307e\u3057\u305f\u3002<br \/>\n\u30b7\u30b9\u30c6\u30e0\u3067\u8aad\u3080\u306e\u3067\u3001\u6587\u5b57\u30b3\u30fc\u30c9\u3092\u300eUTF-8\u300f\u306b\u7d71\u4e00\u3057\u3066\u6240\u5b9a\u306e\u6587\u5b57\u304c\u3042\u308b\u304b\u5224\u65ad\u3055\u305b\u3088\u3046\u3068\u3044\u3046\u3082\u306e\u3002<\/p>\n<p>\u65e7\u30b7\u30b9\u30c6\u30e0\u3067\u306f\u3057\u3063\u304b\u308a\u52d5\u3044\u3066\u3044\u305f\u306e\u3067\u3059\u304c\u3001\u306a\u305c\u304b\u30a8\u30e9\u30fc\u3002<br \/>\n\u5f15\u6570\u306e \"auto\" \u304c\u8aad\u3081\u306a\u3044\u4e8b\u304c\u539f\u56e0\u306e\u69d8\u3067\u3059\u3002<\/p>\n<h3>\u30b5\u30a4\u30c8\u306e\u6587\u5b57\u30b3\u30fc\u30c9\u3092\u5148\u306b\u53d6\u5f97\u3057\u3066\u5f15\u6570\u306b\u6d41\u3057\u8fbc\u3093\u3067\u89e3\u6c7a<\/h3>\n<p>\u3053\u3093\u306a\u611f\u3058\u306b\u3057\u307e\u3057\u305f\u3002<\/p>\n<pre class=\"lang:default decode:true\">if(($Responce = @file_get_contents($url)) == FALSE )\r\n    {\r\n    \/\/ HTTP\u30b9\u30c6\u30fc\u30bf\u30b9\u30b3\u30fc\u30c9\u3092\u53d6\u5f97\u3059\u308b\r\n    $status_code = explode(' ',$Responce[0], 3);\r\n    \/\/ \u30b9\u30c6\u30fc\u30bf\u30b9\u30b3\u30fc\u30c9\u3054\u3068\u306e\u51e6\u7406\r\n    switch($status_code)\r\n        {\r\n        case 404: \/\/echo \"404: Not found.\";\r\n        break;\r\n        default: \/\/return \"ERROR ${status_code}\";\r\n        break;\r\n        }\r\n    }\r\n    else \/\/\u6b63\u5e38\u306bfile_get_contents\u3067\u53d6\u5f97\u3067\u304d\u305f\u5834\u5408\u306e\u51e6\u7406\r\n    {\r\n    \/\/charset\u306e\u53d6\u5f97\r\n    $charset = mb_detect_encoding($url,'ASCII,JIS,UTF-8,EUC-JP,SJIS');\r\n\r\n    \/\/\u8a72\u5f53\u306a\u3057\u30da\u30fc\u30b8\u306e\u9664\u5916\r\n    $stl = mb_convert_encoding($Responce,\"UTF-8\" ,$charset);\r\n    preg_match( \"\/&lt;title&gt;(.*?)&lt;\\\/title&gt;\/i\", $Responce, $matches);\r\n\r\n    if(isset($matches[1]))\r\n        {\r\n        switch ($matches[1])\r\n            {\r\n            case \"\u8a72\u5f53\u30da\u30fc\u30b8\u304c\u3054\u3056\u3044\u307e\u305b\u3093\":\r\n            case \"\uff37\uff21\uff24\uff21\uff38\u30ec\u30f3\u30bf\u30eb\u30b5\u30fc\u30d0\u30fc\":\r\n            break;\r\n            }\r\n<\/pre>\n<p>$charset = mb_detect_encoding($url,'ASCII,JIS,UTF-8,EUC-JP,SJIS'); \u3067\u30a8\u30f3\u30b3\u30fc\u30c9\u3092\u8abf\u3079\u3066<br \/>\n$check_title = mb_convert_encoding($sResponce,\"UTF-8\" ,$charset); \u306e\u5f15\u6570\u3068\u3057\u3066\u683c\u7d0d<\/p>\n<p>case\u306e\u5834\u5408\u5206\u3051\u306f\u53d6\u5f97\u3057\u3066\u304f\u308b\u30b5\u30a4\u30c8\u306e\u51fa\u3059\u30a8\u30e9\u30fc\u30da\u30fc\u30b8\u306e\u30bf\u30a4\u30c8\u30eb\u3092\u8a18\u8f09\u3057\u307e\u3059\u3002<br \/>\n\u3053\u308c\u3067404\u30a8\u30e9\u30fc\u306e\u6642\u306b\u300e\u30da\u30fc\u30b8\u304c\u3054\u3056\u3044\u307e\u305b\u3093\u300f\u30da\u30fc\u30b8\u3078\u98db\u3070\u3059\u4ed5\u7d44\u307f\u304c\u3042\u3063\u3066\u3082\u7121\u4e8b\u98db\u3070\u305b\u307e\u3059\u3002<\/p>\n<h3>\u00a0\u307e\u3068\u3081<\/h3>\n<p>\u305d\u308c\u306b\u3057\u3066\u3082 fail_get_contents \u304c\u91cd\u3044\u3002<\/p>\n<p>Amazon\u753b\u50cf\u306e\u53d6\u5f97\u306f\u3084\u3063\u3071\u308a\u81ea\u52d5\u5316\u3057\u306a\u3044\u3068\u30c0\u30e1\u304b\u306a\u3068\u601d\u3046\u4eca\u65e5\u3053\u306e\u9803\u3067\u3059\u3002<br \/>\n\u203b\u3067\u3082\u306d\u3001\u81ea\u52d5\u5316\u3059\u308b\u3068JAN\u9593\u9055\u3048\u3066\u308b\u5546\u54c1\u753b\u50cf\u3082\u6301\u3063\u3066\u304d\u3061\u3083\u3046\u3093\u3067\u3059\u3088(\u60a9)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Laravel\uff1amb_convert_encoding \u304c\u539f\u56e0\u3067\u30a8\u30e9\u30fc\u767a\u751f \u65e7\u30b7\u30b9\u30c6\u30e0\u3067\u306f\u52d5\u3044\u3066\u3044\u305f\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u79fb\u690d(\u591a\u5c11\u4fee\u6b63)\u3057\u305f\u7d50\u679c\u3001\u30a8\u30e9\u30fc\u767a\u751f\u3002 $check_title = mb_convert_encoding [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":944,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"vkexunit_cta_each_option":"","footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[34],"tags":[54,153,256,98,53,49,62,45],"class_list":["post-1143","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php-memorandum","tag-html","tag-laravel","tag-null","tag-php","tag-53","tag-49","tag-62","tag-45"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/qol-kk.com\/wp2\/wp-content\/uploads\/2018\/11\/laravel_logo.png","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/posts\/1143","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/comments?post=1143"}],"version-history":[{"count":0,"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/posts\/1143\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/media\/944"}],"wp:attachment":[{"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/media?parent=1143"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/categories?post=1143"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/tags?post=1143"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}