{"id":182,"date":"2008-02-12T21:54:31","date_gmt":"2008-02-12T12:54:31","guid":{"rendered":"http:\/\/ke-tai.org\/blog\/2008\/02\/12\/smarty_tips\/"},"modified":"2008-02-13T19:17:25","modified_gmt":"2008-02-13T10:17:25","slug":"smarty_tips","status":"publish","type":"post","link":"http:\/\/ke-tai.org\/blog\/2008\/02\/12\/smarty_tips\/","title":{"rendered":"\u643a\u5e2f\u30b5\u30a4\u30c8\u3067Smarty\u3092\u4f7f\u3046\u5834\u5408\u306e\u6ce8\u610f\u70b9"},"content":{"rendered":"<p>\u300c\u30b1\u30fc\u30bf\u30a4\u30b5\u30a4\u30c8\u306bSmarty\u3092\u4f7f\u304a\u3046\u3068\u3057\u305f\u304c\u3046\u307e\u304f\u3044\u304b\u306a\u3044\u300d\u3068\u3044\u3046\u8cea\u554f\u3092\u3088\u304f\u53d7\u3051\u308b\u3053\u3068\u304c\u3042\u308b\u306e\u3067\u3001\u6ce8\u610f\u70b9\u3092\u307e\u3068\u3081\u3066\u307f\u307e\u3059\u3002<\/p>\n<p>\u554f\u984c\u3068\u306a\u308b\u306e\u306f\u3001\u6587\u5b57\u30b3\u30fc\u30c9\u306b\u300cShift_JIS\u300d\u3092\u4f7f\u3063\u305f\u5834\u5408\u3067\u3059\u3002<br \/>\n\u6700\u8fd1\u306f\u5bfe\u5fdc\u7aef\u672b\u304c\u5897\u3048\u305f\u305f\u3081\u3001UTF-8\u3067\u30da\u30fc\u30b8\u3092\u4f5c\u308b\u5834\u5408\u3082\u591a\u3044\u3067\u3059\u304c\u3001\u904e\u53bb\u306e\u8cc7\u7523\u3084\u3089\u3001\u4e92\u63db\u6027\u306e\u554f\u984c\u3084\u3089\u3067Shift_JIS\u3092\u4f7f\u3046\u3053\u3068\u3082\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u3068\u3053\u308d\u304cSmarty\u3067\u306fSJIS\u306f\u4f7f\u3048\u307e\u305b\u3093\u3002<br \/>\n\u306a\u305c\u306a\u3089\u3001Smarty\u306e\u6a19\u6e96\u306e\u30c7\u30ea\u30df\u30bf\u3067\u3042\u308b<\/p>\n<p>\u300c <strong>{<\/strong> \u300d (0x007b)\u3001 \u3000\u300c <strong>}<\/strong> \u300d (0x007d)<\/p>\n<p>\u3092\u3001SJIS\u6587\u5b57\u5217\u304c\u542b\u3093\u3067\u3057\u307e\u3063\u3066\u3044\u308b\u3053\u3068\u304c\u3042\u308b\u304b\u3089\u3067\u3059\u3002<br \/>\n<strong>\uff08\u3064\u307e\u308a\u5fc5\u305a\u3057\u3082\u30a8\u30e9\u30fc\u306b\u306f\u306a\u3089\u306a\u3044\u3053\u3068\u306b\u6ce8\u610f\u304c\u5fc5\u8981\u3067\u3059\uff09<\/strong><\/p>\n<p>\u30a8\u30e9\u30fc\u304c\u8d77\u3053\u3063\u305f\u5834\u5408\u306b\u306f\u6b21\u306e\u3088\u3046\u306a\u30e1\u30c3\u30bb\u30fc\u30b8\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u3002<\/p>\n<p class=\"super-pre-small\"> Fatal error: Smarty error: [in path\/to\/tpl.html line 10]: syntax error: unrecognized tag: \u2039 (Smarty_Compiler.class.php, line 446) in \/path\/to\/Smarty\/Smarty.class.php on line 1095<\/p>\n<p>\u3053\u308c\u3092\u56de\u907f\u3059\u308b\u306b\u306f\u3001\u4e3b\u306b\u6b21\u306e2\u3064\u306e\u65b9\u6cd5\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p class=\"spacer-small\">&nbsp;<\/p>\n<p><strong>1. \u30c7\u30ea\u30df\u30bf\u3092\u5909\u66f4\u3059\u308b<\/strong><\/p>\n<p>\u6ce2\u30ab\u30c3\u30b3\u304c\u60aa\u3055\u3092\u3057\u3066\u3044\u308b\u306e\u3067\u3001\u305d\u308c\u3092\u5909\u66f4\u3057\u3066\u3057\u307e\u3048\u3070\u5927\u4e08\u592b\u3067\u3059\u3002<br \/>\n\u6b21\u306e\u3088\u3046\u306b\u3057\u3066\u30c7\u30ea\u30df\u30bf\u3092\u5909\u66f4\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"super-pre-small\"><code>$smarty-&gt;left_delimiter = '{{';\r\n$smarty-&gt;right_delimiter = '}}';<\/code><\/pre>\n<p>\u30c7\u30ea\u30df\u30bf\u3092\u5909\u66f4\u3057\u305f\u5834\u5408\u306f\u3001\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u5185\u306e\u4ed6\u306eSmarty\u30bf\u30b0\u3082\u5fd8\u308c\u305a\u306b\u5909\u66f4\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre class=\"super-pre-small\">\u4fee\u6b63\u524d\u3000\uff1a\u3000{$hoge}\r\n\u4fee\u6b63\u5f8c\u3000\uff1a\u3000{{$hoge}}<\/pre>\n<p>\u4ed6\u306b\u3082\u300c&lt;{$hoge}&gt;\u300d\u306a\u3093\u304b\u3092\u4f7f\u3046\u4eba\u3082\u3044\u307e\u3059\u3002\u3053\u306e\u8fba\u308a\u306f\u597d\u307f\u306e\u554f\u984c\u3067\u3059\u3002<\/p>\n<p class=\"spacer-small\">&nbsp;<\/p>\n<p><strong>2\uff0e\u30d7\u30ea\u30d5\u30a3\u30eb\u30bf\u3068\u30dd\u30b9\u30c8\u30d5\u30a3\u30eb\u30bf\u3092\u8a2d\u5b9a\u3059\u308b<\/strong><\/p>\n<p>\u30d7\u30ea\u30d5\u30a3\u30eb\u30bf\u3068\u30dd\u30b9\u30c8\u30d5\u30a3\u30eb\u30bf\u3092\u8a2d\u5b9a\u3059\u308b\u3053\u3068\u3067\u3001Smarty\u3067\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u304c\u51e6\u7406\u3055\u308c\u308b\u969b\u306b\u3001\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u304cEUC-JP\u3068\u3057\u3066\u51e6\u7406\u3055\u308c\u3001\u305d\u306e\u5f8c\u518d\u3073SJIS\u3068\u306a\u3063\u3066\u51fa\u529b\u3055\u308c\u307e\u3059\u3002<\/p>\n<p><small>\u203b\u3053\u306e\u65b9\u6cd5\u3092\u4f7f\u3063\u305f\u5834\u5408\u306b\u306f\u3001\u30c9\u30b3\u30e2\u306eSJIS\u5f62\u5f0f\u306e\u7d75\u6587\u5b57\u304c\u6587\u5b57\u5316\u3051\u3057\u3066\u3057\u307e\u3046\u306e\u3067\u6ce8\u610f\u304c\u5fc5\u8981\u3067\u3059\u3002<br \/>\n\u7d75\u6587\u5b57\u3092\u4f7f\u3044\u305f\u3044\u5834\u5408\u306fSJIS\u65b9\u5f0f\u3067\u306f\u306a\u304f\u3001&xxxxx;\u65b9\u5f0f\u3067\u66f8\u304d\u307e\u3057\u3087\u3046\u3002<\/small><\/p>\n<pre class=\"super-pre-small\"><code>$smarty-&gt;register_prefilter(\"convert_encoding_to_eucjp\");\r\n$smarty-&gt;register_postfilter(\"convert_encoding_to_sjis\");\r\n\r\n\/\/--------------------------------\r\n\/\/ Smarty SJIS\u5bfe\u5fdc\u7528\u95a2\u65701\r\n\/\/--------------------------------\r\nfunction convert_encoding_to_eucjp($template_source) {\r\n    if (function_exists(\"mb_convert_encoding\")) {\r\n        \/\/\u6587\u5b57\u30b3\u30fc\u30c9\u3092\u5909\u63db\u3059\u308b\r\n        return mb_convert_encoding($template_source, \"EUC-JP\", \"SJIS\");\r\n    }\r\n    return $template_source;\r\n}\r\n\r\n\/\/--------------------------------\r\n\/\/ Smarty SJIS\u5bfe\u5fdc\u7528\u95a2\u65702\r\n\/\/--------------------------------\r\nfunction convert_encoding_to_sjis($template_source) {\r\n    if (function_exists(\"mb_convert_encoding\")) {\r\n        \/\/\u6587\u5b57\u30b3\u30fc\u30c9\u3092\u5909\u63db\u3059\u308b\r\n        return mb_convert_encoding($template_source, \"SJIS\", \"EUC-JP\");\r\n    }\r\n    return $template_source;\r\n}\r\n<\/code><\/pre>\n<p class=\"spacer-small\">&nbsp;<\/p>\n<p><strong>3. \u691c\u8a3c<\/strong><\/p>\n<p>\u691c\u8a3c\u306f\u6587\u5b57\u30b3\u30fc\u30c9\u306e\u4e2d\u306b\u300c{\u300d\u3084\u300c}\u300d\u3092\u542b\u3093\u3067\u3044\u308b\u6587\u5b57\u3092\u66f8\u3044\u3066\u3084\u308c\u3070\uff2f\uff2b\u3067\u3059\u3002<br \/>\n\uff08\u4f8b\uff1a\u300c\u95b2\u300d\u300c\u53ad\u300d\u300c\u5bae\u300d\u300c\u6025\u300d\u300c\u9d8f\u300d\u300c\u8fce\u300d\u306a\u3069\uff09<\/p>\n<p>\u4f8b\u3048\u3070\u300c\u9d8f\u3092\u8fce\u3048\u8a0e\u3064\u300d\u306a\u3069\u3068SJIS\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306b\u8a18\u8f09\u3057\u3001\u8868\u793a\u3055\u308c\u308c\u3070\u5927\u4e08\u592b\u3068\u3044\u3046\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p class=\"spacer-small\">&nbsp;<\/p>\n<p><strong>4. \u307e\u3068\u3081<\/strong><\/p>\n<ul>\n<li>Smarty\u306f\u3001\u305d\u306e\u307e\u307e\u3067\u306fShift_JIS\u306f\u4f7f\u3048\u306a\u3044<br \/>\n\uff08\u305f\u3060\u3057\u534a\u7aef\u306b\u52d5\u4f5c\u3059\u308b\u3053\u3068\u306b\u6ce8\u610f\uff09<\/li>\n<li>SJIS\u3092\u4f7f\u3044\u305f\u3044\u5834\u5408\u306f\u3001\u30c7\u30ea\u30df\u30bf\u3092\u5909\u3048\u308b\u304b\u3001\u30d7\u30ea\u30d5\u30a3\u30eb\u30bf\u30fb\u30dd\u30b9\u30c8\u30d5\u30a3\u30eb\u30bf\u3092\u4f7f\u3046<\/li>\n<li>\u691c\u8a3c\u306f\u300c\u95b2\u300d\u300c\u53ad\u300d\u300c\u5bae\u300d\u300c\u6025\u300d\u300c\u9d8f\u300d\u300c\u8fce\u300d\u306a\u3069\u3067<\/li>\n<\/ul>\n<p class=\"spacer\">&nbsp;<\/p>\n<p><strong><em>\u95a2\u9023\uff1a<\/em><\/strong><\/p>\n<ul>\n<li><em><a href=\"http:\/\/ke-tai.org\/blog\/2007\/11\/26\/henkan_tips\/\">PHP\u3067\u7d75\u6587\u5b57\u3092\u58ca\u3055\u305a\u306b\u6587\u5b57\u30b3\u30fc\u30c9\u3084\u5168\u89d2\u534a\u89d2\u5909\u63db\u3092\u884c\u3046\u65b9\u6cd5  <\/a><\/em><\/li>\n<li><em><a href=\"http:\/\/ke-tai.org\/blog\/2007\/11\/24\/iemoji_conv2\/\">i\u30e2\u30fc\u30c9\u7d75\u6587\u5b57\u3092Unicode\u5f62\u5f0f\u304b\u3089SJIS\u5f62\u5f0f\u306b\u9006\u5909\u63db\u3059\u308bPHP\u30b5\u30f3\u30d7\u30eb<\/a><\/em><\/li>\n<li><em><a href=\"http:\/\/ke-tai.org\/blog\/2007\/11\/23\/iemoji_conv1\/\">i\u30e2\u30fc\u30c9\u7d75\u6587\u5b57\u3092SJIS\u5f62\u5f0f\u304b\u3089Unicode\u5f62\u5f0f\u306b\u5909\u63db\u3059\u308bPHP\u30b5\u30f3\u30d7\u30eb<\/a><\/em><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u300c\u30b1\u30fc\u30bf\u30a4\u30b5\u30a4\u30c8\u306bSmarty\u3092\u4f7f\u304a\u3046\u3068\u3057\u305f\u304c\u3046\u307e\u304f\u3044\u304b\u306a\u3044\u300d\u3068\u3044\u3046\u8cea\u554f\u3092\u3088\u304f\u53d7\u3051\u308b\u3053\u3068\u304c\u3042\u308b\u306e\u3067\u3001\u6ce8\u610f\u70b9\u3092\u307e\u3068\u3081\u3066\u307f\u307e\u3059\u3002 \u554f\u984c\u3068\u306a\u308b\u306e\u306f\u3001\u6587\u5b57\u30b3\u30fc\u30c9\u306b\u300cShift_JIS\u300d\u3092\u4f7f\u3063\u305f\u5834\u5408\u3067\u3059\u3002 \u6700\u8fd1\u306f\u5bfe\u5fdc\u7aef\u672b\u304c\u5897\u3048\u305f\u305f [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[7],"tags":[],"_links":{"self":[{"href":"http:\/\/ke-tai.org\/blog\/wp-json\/wp\/v2\/posts\/182"}],"collection":[{"href":"http:\/\/ke-tai.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/ke-tai.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/ke-tai.org\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/ke-tai.org\/blog\/wp-json\/wp\/v2\/comments?post=182"}],"version-history":[{"count":0,"href":"http:\/\/ke-tai.org\/blog\/wp-json\/wp\/v2\/posts\/182\/revisions"}],"wp:attachment":[{"href":"http:\/\/ke-tai.org\/blog\/wp-json\/wp\/v2\/media?parent=182"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/ke-tai.org\/blog\/wp-json\/wp\/v2\/categories?post=182"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/ke-tai.org\/blog\/wp-json\/wp\/v2\/tags?post=182"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}