{"id":155,"date":"2007-06-17T00:02:13","date_gmt":"2007-06-16T16:02:13","guid":{"rendered":"http:\/\/twycf.com\/wordpress\/archives\/155"},"modified":"2007-06-17T00:02:13","modified_gmt":"2007-06-16T16:02:13","slug":"iconv-%e8%bd%89%e7%a2%bc%e5%95%8f%e9%a1%8c","status":"publish","type":"post","link":"https:\/\/twycf.com\/?p=155","title":{"rendered":"iconv \u8f49\u78bc\u554f\u984c"},"content":{"rendered":"<p>\u525b\u525b\u5728\u8655\u7406 MsSQL(big5) \u8f49 MySQL(UTF8)\u6642\uff0c\u63a1\u7528\u4e86 iconv \u53bb\u505a\u8f49\u78bc\u7684\u8655\u7406<br \/>\n\u4e00\u958b\u59cb\u8655\u7406\u5e7e\u500b Table \u90fd\u6c92\u4ec0\u9ebc\u554f\u984c\uff0c\u76f4\u5230\u4e00\u500b\u6b04\u4f4d\u88e1\u9762\u6709\u4e2d\u6587\u5168\u5f62&#8221;\uff0f\u300d\uff0c\u5f15\u8d77 iconv \u7121\u6cd5\u8f49\u63db\u800c\u6574\u500b SQL \u53e5\u5b50\u4e2d\u65b7<!--more--><br \/>\niconv \u8a9e\u6cd5<br \/>\n<coolcode linenum=\"off\"><br \/>\niconv(FromEncoding, ToEncoding, String);<\/coolcode><br \/>\n\u4e0a\u7db2\u67e5\u5230 iconv \u7b2c\u4e8c\u500b\u53c3\u6578\u53ef\u4ee5\u52a0\u4e0a\u984d\u5916\u53c3\u6578<br \/>\n<coolcode linenum=\"off\"><br \/>\n  \/\/IGNORE\u76f4\u63a5\u628a\u932f\u8aa4\u7684\u5b57\u53bb\u6389\uff0c\u4f7f\u7528\u4e0a\u6b63\u5e38\uff0c\u4f46\u662f\u8cc7\u6599\u8207\u539f\u59cb\u7684\u4e0d\u540c<br \/>\n  $txt = iconv(&#8220;big5&#8243;,&#8221;utf-8\/\/IGNORE&#8221;,$query);<br \/>\n  \/\/TRANSLIT\u9047\u5230\u4e2d\u6587\u7684&#8221;\uff0f&#8221;\u9084\u662f\u51fa\u932f<br \/>\n  $txt = iconv(&#8220;big5&#8243;,&#8221;utf-8\/\/TRANSLIT&#8221;,$query);<br \/>\n<\/coolcode><br \/>\n\u9019\u908a\u6709\u4e00\u7bc7\u95dc\u65bc Translit \u53c3\u6578\u7684\u8aaa\u660e<br \/>\n<a href=\"http:\/\/groups.google.com\/group\/ruby-talk-google\/browse_thread\/thread\/96c75d3587012556\">Iconv and incompatible encodings<\/a><br \/>\n\u6587\u7ae0\u4e2d\u6307\u51fa<br \/>\n<coolcode linenum=\"off\"><br \/>\n\/\/TRANSLIT will raise an exception on characters it can&#8217;t transliterate, however; this can be solved by using &#8216;\/\/IGNORE\/\/TRANSLIT&#8217; together (in that order).<br \/>\n<\/coolcode><br \/>\n\u6700\u5f8c\u662f\u63a1\u7528\u4e86 mb_convert_encoding \u4f86\u89e3\u6c7a<br \/>\n<coolcode linenum=\"off\"><br \/>\n  \/\/mb_convert_encoding \u53ef\u4ee5\u6b63\u5e38\u7684\u628a\u5b57\u4e32\u8f49\u70ba UTF8\uff0c\u4f46\u807d\u8aaa\u901f\u5ea6\u8f03\u6162<br \/>\n  $txt = mb_convert_encoding($query,&#8221;utf-8&#8243;,&#8221;big5&#8243;);<br \/>\n<\/coolcode><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u525b\u525b\u5728\u8655\u7406 MsSQL(big5) \u8f49 MySQL(UTF8)\u6642\uff0c\u63a1\u7528\u4e86 iconv \u53bb\u505a\u8f49\u78bc\u7684\u8655\u7406 \u4e00\u958b\u59cb\u8655 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-155","post","type-post","status-publish","format-standard","hentry","category-php"],"_links":{"self":[{"href":"https:\/\/twycf.com\/index.php?rest_route=\/wp\/v2\/posts\/155","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/twycf.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/twycf.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/twycf.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/twycf.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=155"}],"version-history":[{"count":0,"href":"https:\/\/twycf.com\/index.php?rest_route=\/wp\/v2\/posts\/155\/revisions"}],"wp:attachment":[{"href":"https:\/\/twycf.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=155"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/twycf.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=155"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/twycf.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=155"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}