{"id":237,"date":"2008-01-06T15:52:53","date_gmt":"2008-01-06T07:52:53","guid":{"rendered":"http:\/\/www.cgdev.net\/blog\/?p=237"},"modified":"2013-07-02T17:32:52","modified_gmt":"2013-07-02T09:32:52","slug":"locale%e4%b8%8efacet","status":"publish","type":"post","link":"https:\/\/www.cgdev.net\/blog\/237.html","title":{"rendered":"locale\u4e0efacet"},"content":{"rendered":"<p>\u4e00. locale<br \/>\n   \u4e00\u4e2a\u6d41\u5728\u521d\u59cb\u5316\u65f6\u5c06\u9690\u5f0f\u5730\u4f7f\u7528\u5168\u5c40locale, \u800c\u521d\u59cb\u65f6\u5019\u7684\u5168\u5c40locale\u5c31\u662f\u6807\u51c6\u7684&#8221;C&#8221;\u6a21\u5f0flocale::classic()<br \/>\n\u5728VC\u4e0e\u4e2d\u6587\u7248xp\u4e0b\uff0c \u4e5f\u662f\u8fd9\u6837\u3002<\/p>\n<p>\u4e8c. \u9759\u6001\u51fd\u6570locale::global(newloc) \u53ef\u8bbe\u7f6enewloc\u4e3a\u5168\u5c40locale\uff0c\u5e76\u4e14\u8fd4\u56de\u4ee5\u524d\u7684\u5168\u5c40locale\uff0c\u53ef\u5c06\u4e4b\u4fdd\u5b58\u8d77\u6765<br \/>\n\u4ee5\u540e\u6062\u590d\uff0c \u968f\u65f6\u8981\u8bb0\u5f97\u6062\u590d\u8fd9\u70b9\u5f88\u91cd\u8981\u3002<br \/>\n   locale newloc(&#8220;&#8221;); \/\/\u5728\u7b80\u4f53\u4e2d\u6587xp\u7cfb\u7edf\u4e0a\u7b49\u4ef7\u4e8e&#8221;.936&#8243;<br \/>\n   locale&#038; oldloc = locale::global(newloc);<br \/>\n   &#8230;<br \/>\n   locale::global(oldloc);<\/p>\n<p>   \u7eafAPI\u65b9\u5f0f\u4e0b\u7528<br \/>\n   setlocale(LC_ALL,&#8221;C&#8221;);<br \/>\n   setlocale(LC_ALL,&#8221;.936&#8243;); \u4e5f\u53ef\u4ee5\u7528 setlocale(LC_ALL,   &#8220;&#8221;);<\/p>\n<p>\u4e09. Bjarne Stroustrup\u63d0\u5230\u7528locale::global(x)\u7684\u65f6\u5019\u5c06\u540c\u65f6\u8bbe\u7f6e\u5168\u5c40locale\uff0c\u4f46\u6211\u5728VC\u4e2d\u6df7\u7528API<br \/>\n\u548cstl\u7684\u6765\u8bbe\u7f6elocale\u65f6\u5019\u6709\u4e9b\u5fae\u5c0f\u7684\u5dee\u522b\uff0c\u6240\u4ee5\u4eca\u540e\u8981\u6ce8\u610f\u6700\u597d\u6210\u5bf9\u5730\u8bbe\u7f6e\uff0c\u4e5f\u5c31\u662f\u7528API\u53bb\u8bbe\u7f6e\uff0c\u4ee5\u540e\u6062\u590d\u4e5f\u7528<br \/>\nAPI\u6765\u505a\uff0c\u76f8\u5e94\u5730\uff0c\u7528stl\u7c7blocale\u53bb\u8bbe\u7f6e\uff0c\u4e5f\u7528\u540c\u6837\u7684\u7c7b\u53bb\u6062\u590d\u56de\u6765\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00. locale \u4e00\u4e2a\u6d41\u5728\u521d\u59cb\u5316\u65f6\u5c06\u9690\u5f0f\u5730\u4f7f\u7528\u5168\u5c40locale, \u800c\u521d\u59cb\u65f6\u5019\u7684\u5168\u5c40locale\u5c31\u662f\u6807\u51c6\u7684&#8221;C&#8221;\u6a21\u5f0flocale::classic() \u5728VC\u4e0e\u4e2d\u6587\u7248xp\u4e0b\uff0c \u4e5f\u662f\u8fd9\u6837\u3002 \u4e8c. \u9759\u6001\u51fd\u6570locale::global(newloc) \u53ef\u8bbe\u7f6enewloc\u4e3a\u5168\u5c40locale\uff0c\u5e76\u4e14\u8fd4\u56de\u4ee5\u524d\u7684\u5168\u5c40locale\uff0c\u53ef\u5c06\u4e4b\u4fdd\u5b58\u8d77\u6765 \u4ee5\u540e\u6062\u590d\uff0c \u968f\u65f6\u8981\u8bb0\u5f97\u6062\u590d\u8fd9\u70b9\u5f88\u91cd\u8981\u3002 locale newloc(&#8220;&#8221;); \/\/\u5728\u7b80\u4f53\u4e2d\u6587xp\u7cfb\u7edf\u4e0a\u7b49\u4ef7\u4e8e&#8221;.936&#8243; locale&#038; oldloc = locale::global(newloc); &#8230; locale::global(oldloc); \u7eafAPI\u65b9\u5f0f\u4e0b\u7528 setlocale(LC_ALL,&#8221;C&#8221;); setlocale(LC_ALL,&#8221;.936&#8243;); \u4e5f\u53ef\u4ee5\u7528 setlocale(LC_ALL, &#8220;&#8221;); \u4e09. Bjarne Stroustrup\u63d0\u5230\u7528locale::global(x)\u7684\u65f6\u5019\u5c06\u540c\u65f6\u8bbe\u7f6e\u5168\u5c40locale\uff0c\u4f46\u6211\u5728VC\u4e2d\u6df7\u7528API \u548cstl\u7684\u6765\u8bbe\u7f6elocale\u65f6\u5019\u6709\u4e9b\u5fae\u5c0f\u7684\u5dee\u522b\uff0c\u6240\u4ee5\u4eca\u540e\u8981\u6ce8\u610f\u6700\u597d\u6210\u5bf9\u5730\u8bbe\u7f6e\uff0c\u4e5f\u5c31\u662f\u7528API\u53bb\u8bbe\u7f6e\uff0c\u4ee5\u540e\u6062\u590d\u4e5f\u7528 API\u6765\u505a\uff0c\u76f8\u5e94\u5730\uff0c\u7528stl\u7c7blocale\u53bb\u8bbe\u7f6e\uff0c\u4e5f\u7528\u540c\u6837\u7684\u7c7b\u53bb\u6062\u590d\u56de\u6765\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-237","post","type-post","status-publish","format-standard","hentry","category-cpp"],"_links":{"self":[{"href":"https:\/\/www.cgdev.net\/blog\/wp-json\/wp\/v2\/posts\/237","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.cgdev.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cgdev.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cgdev.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cgdev.net\/blog\/wp-json\/wp\/v2\/comments?post=237"}],"version-history":[{"count":0,"href":"https:\/\/www.cgdev.net\/blog\/wp-json\/wp\/v2\/posts\/237\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.cgdev.net\/blog\/wp-json\/wp\/v2\/media?parent=237"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cgdev.net\/blog\/wp-json\/wp\/v2\/categories?post=237"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cgdev.net\/blog\/wp-json\/wp\/v2\/tags?post=237"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}