Skip to content

Commit 6190bb8

Browse files
Preview PR 1542: 1cf31ac0b61755
1 parent 728f645 commit 6190bb8

4 files changed

Lines changed: 83 additions & 50 deletions

File tree

gen/pull/1542/PREVIEW.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# PR [\#1542](https://github.com/cpprefjp/site/pull/1542) プレビュー
2-
- ⌚ 更新時刻: 2025-12-03 22:53:46 JST
2+
- ⌚ 更新時刻: 2025-12-04 00:31:47 JST
33
- 🔍 [プレビュー (HTML)](https://cpprefjp.github.io/site/gen/pull/1542)
44
- 📈 [プレビュー生成記録](https://github.com/cpprefjp/site/actions?query=event%3Apull_request_target+branch%3Aclocale)
5-
- **⫯** ソースの変更: [`0b61755..3da3fbc`](https://github.com/cpprefjp/site/compare/0b61755bd12efe68418cb790b84cf00cd8667ea5..3da3fbcb87e30401583bf5ac3e11a6fbfb51f0c1)
5+
- **⫯** ソースの変更: [`0b61755..1cf31ac`](https://github.com/cpprefjp/site/compare/0b61755bd12efe68418cb790b84cf00cd8667ea5..1cf31acb644fd3585d103572247dc2f8bbb36ef9)
66

77
## 変更記事一覧 (12件)
88

gen/pull/1542/reference/clocale/setlocale.html

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868

6969
</head>
7070
<body>
71-
<header data-kunai-mdinfo="{&#34;meta&#34;: {&#34;header&#34;: [&#34;clocale&#34;], &#34;namespace&#34;: [&#34;std&#34;], &#34;id-type&#34;: [&#34;function&#34;]}, &#34;sources&#34;: [{&#34;id&#34;: &#34;3d2e2a51f3f4b9080159dc2e88eef78bd7b9aabb&#34;, &#34;source&#34;: &#34;#include &lt;iostream&gt;\n#include &lt;clocale&gt;\n\nint main(){\n // \u65e5\u672c\u8a9e\u30ed\u30b1\u30fc\u30eb\u306b\u8a2d\u5b9a\n if (!std::setlocale(LC_ALL, \&#34;ja_JP.UTF-8\&#34;)) {\n std::cerr &lt;&lt; \&#34;Failed to set locale\\n\&#34;;\n return 1;\n }\n\n // \u73fe\u5728\u306e\u5168\u30ab\u30c6\u30b4\u30ea\u306e\u30ed\u30b1\u30fc\u30eb\u3092\u53d6\u5f97\n std::cout &lt;&lt; \&#34;Current locale: \&#34; &lt;&lt; std::setlocale(LC_ALL, NULL) &lt;&lt; \&#34;\\n\&#34;;\n\n // \u6570\u5024\u30ab\u30c6\u30b4\u30ea\u3060\u3051\u78ba\u8a8d\n std::cout &lt;&lt; \&#34;Numeric locale: \&#34; &lt;&lt; std::setlocale(LC_NUMERIC, NULL) &lt;&lt; \&#34;\\n\&#34;;\n}\n\n&#34;}], &#34;page_id&#34;: [&#34;reference&#34;, &#34;clocale&#34;, &#34;setlocale&#34;]}">
71+
<header data-kunai-mdinfo="{&#34;meta&#34;: {&#34;header&#34;: [&#34;clocale&#34;], &#34;namespace&#34;: [&#34;std&#34;], &#34;id-type&#34;: [&#34;function&#34;]}, &#34;sources&#34;: [{&#34;id&#34;: &#34;c3e6e209366ae19fe0aa7b1d9c07fba68c52b14d&#34;, &#34;source&#34;: &#34;#include &lt;iostream&gt;\n#include &lt;clocale&gt;\n\nint main() {\n // \u65e5\u672c\u8a9e\u30ed\u30b1\u30fc\u30eb\u306b\u8a2d\u5b9a\n if (!std::setlocale(LC_ALL, \&#34;ja_JP.UTF-8\&#34;)) {\n std::cerr &lt;&lt; \&#34;Failed to set locale\\n\&#34;;\n return 1;\n }\n\n // \u73fe\u5728\u306e\u5168\u30ab\u30c6\u30b4\u30ea\u306e\u30ed\u30b1\u30fc\u30eb\u3092\u53d6\u5f97\n std::cout &lt;&lt; \&#34;Current locale: \&#34; &lt;&lt; std::setlocale(LC_ALL, NULL) &lt;&lt; \&#34;\\n\&#34;;\n\n // \u6570\u5024\u30ab\u30c6\u30b4\u30ea\u3060\u3051\u78ba\u8a8d\n std::cout &lt;&lt; \&#34;Numeric locale: \&#34; &lt;&lt; std::setlocale(LC_NUMERIC, NULL) &lt;&lt; \&#34;\\n\&#34;;\n}\n\n&#34;}], &#34;page_id&#34;: [&#34;reference&#34;, &#34;clocale&#34;, &#34;setlocale&#34;]}">
7272
<nav class="navbar navbar-default" role="navigation">
7373
<div class="container-fluid">
7474
<div class="navbar-header">
@@ -188,8 +188,8 @@
188188

189189
<p class="text-right"><small>
190190
最終更新日時(UTC):
191-
<span itemprop="datePublished" content="2025-12-03T13:38:50">
192-
2025年12月03日 13時38分50秒
191+
<span itemprop="datePublished" content="2025-12-03T15:13:16">
192+
2025年12月03日 15時13分16秒
193193
</span>
194194
<br/>
195195
<span itemprop="author" itemscope itemtype="http://schema.org/Person">
@@ -214,30 +214,32 @@
214214

215215
<div class="identifier-type">function</div><div class="header">&lt;clocale&gt;</div><h1 itemprop="name"><span class="namespace" title="namespace std">std::</span><span class="token">setlocale</span></h1>
216216
<div itemprop="articleBody"><p><div class="codehilite"><pre><span></span><code><span class="k">namespace</span> <span class="n">std</span> <span class="p">{</span>
217-
<span class="kt">char</span><span class="o">*</span> <span class="n">setlocale</span><span class="p">(</span><span class="kt">int</span> <span class="n">category</span><span class="p">,</span> <span class="k">const</span> <span class="kt">char</span><span class="o">*</span> <span class="n">locale</span><span class="p">);</span>
217+
<span class="kt">char</span><span class="o">*</span> <span class="n">setlocale</span><span class="p">(</span><span class="kt">int</span> <span class="n">category</span><span class="p">,</span> <span class="k">const</span> <span class="kt">char</span><span class="o">*</span> <span class="n">locale</span><span class="p">);</span>
218218
<span class="p">}</span>
219219
</code></pre></div>
220220
</p>
221221
<h2>概要</h2>
222222
<p>指定したカテゴリのロケールを設定、または現在のロケールを取得する。</p>
223-
<p>指定できるロケール文字列は<a href="../../article/platform/locales.html">以下のページ</a>である</p>
223+
<p>指定できる<a class="cpprefjp-defined-word" data-desc="処理系定義の動作。処理系によって事前に定めた動作をする" href="../../implementation-compliance.html#dfn-implementation-defined-behavior">処理系定義</a>のロケール文字列は<a href="../../article/platform/locales.html">使用できるロケール文字列</a>を参照のこと</p>
224224
<h2>引数</h2>
225225
<ul>
226226
<li><code>category</code>:設定対象のカテゴリ。<code>LC_ALL</code>,<code>LC_CTYPE</code>などのマクロを使用。</li>
227227
<li><code>locale</code><ul>
228-
<li>"C":標準のCロケール</li>
229-
<li>"":環境依存のデフォルトロケール</li>
228+
<li><code>"C"</code>:標準のCロケール</li>
229+
<li><code>""</code>:環境依存のデフォルトロケール</li>
230230
<li><code>NULL</code>:現在のロケールを取得するだけ</li>
231231
</ul>
232232
</li>
233233
</ul>
234234
<h2><a class="cpprefjp-defined-word" data-desc="関数呼び出し式の評価結果となるオブジェクト・値">戻り値</a></h2>
235235
<p>成功時は設定されたロケール名(文字列)、失敗時は<code>NULL</code></p>
236+
<p>返された文字列をプログラムで変更してはならない。</p>
237+
<p><code>setlocale()</code> を呼び出したスレッドが終了した後、もしくは更に次の <code>setlocale()</code> の呼び出しの後に返された文字列を使った時の<a class="cpprefjp-defined-word" data-desc="未定義の動作。処理系は予期せぬ動作をする可能性がある。要するに動作保証対象外。undefined behavior (UB)。" href="../../implementation-compliance.html#dfn-undefined-behavior">動作は未定義</a>である。</p>
236238
<h2></h2>
237-
<p><div class="yata" id="3d2e2a51f3f4b9080159dc2e88eef78bd7b9aabb"><div class="codehilite"><pre><span></span><code><span class="cp">#include</span> <span class="cpf"><a href="../iostream.html">&lt;iostream&gt;</a></span><span class="cp"></span>
239+
<p><div class="yata" id="c3e6e209366ae19fe0aa7b1d9c07fba68c52b14d"><div class="codehilite"><pre><span></span><code><span class="cp">#include</span> <span class="cpf"><a href="../iostream.html">&lt;iostream&gt;</a></span><span class="cp"></span>
238240
<span class="cp">#include</span> <span class="cpf">&lt;clocale&gt;</span><span class="cp"></span>
239241

240-
<span class="kt">int</span> <span class="nf">main</span><span class="p">(){</span>
242+
<span class="kt">int</span> <span class="nf">main</span><span class="p">()</span> <span class="p">{</span>
241243
<span class="c1">// 日本語ロケールに設定</span>
242244
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="n">std</span><span class="o">::</span><span class="n">setlocale</span><span class="p">(</span><span class="n">LC_ALL</span><span class="p">,</span> <span class="s">"ja_JP.UTF-8"</span><span class="p">))</span> <span class="p">{</span>
243245
<span class="n">std</span><span class="o">::</span><span class="n">cerr</span> <span class="o">&lt;&lt;</span> <span class="s">"Failed to set locale</span><span class="se">\n</span><span class="s">"</span><span class="p">;</span>
@@ -258,7 +260,7 @@ <h3>出力</h3>
258260
</code></pre></p>
259261
<h2>関連項目</h2>
260262
<ul>
261-
<li><a href="../../article/platform/locales.html"> ロケール文字一覧 </a></li>
263+
<li><a href="../../article/platform/locales.html"> ロケール文字列一覧 </a></li>
262264
<li><a href="../locale/locale.html"> <code>std::locale</code> </a></li>
263265
</ul></div>
264266

gen/pull/1542/rss.xml

Lines changed: 68 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,76 @@
22
<feed xmlns="http://www.w3.org/2005/Atom">
33
<title>cpprefjp - C++日本語リファレンス</title>
44
<link href="https://cpprefjp.github.io" />
5-
<updated>2025-12-03T13:53:45.469055</updated>
6-
<id>d31c2584-8090-4178-99d0-94e5ebadb5c2</id>
5+
<updated>2025-12-03T15:31:46.489385</updated>
6+
<id>852af33b-46ed-4038-942b-c88e558e41e1</id>
77

88

9+
<entry>
10+
<title>setlocale -- 指摘された点を変更</title>
11+
<link href="https://cpprefjp.github.io/reference/clocale/setlocale.html"/>
12+
<id>1cf31acb644fd3585d103572247dc2f8bbb36ef9:reference/clocale/setlocale.md</id>
13+
<updated>2025-12-04T00:13:16+09:00</updated>
14+
15+
<summary type="html">&lt;pre&gt;&lt;code&gt;diff --git a/reference/clocale/setlocale.md b/reference/clocale/setlocale.md
16+
index e2934913f..2fe7636c1 100644
17+
--- a/reference/clocale/setlocale.md
18+
+++ b/reference/clocale/setlocale.md
19+
@@ -5,31 +5,35 @@
20+
21+
```cpp
22+
namespace std {
23+
- char* setlocale(int category, const char* locale);
24+
+ char* setlocale(int category, const char* locale);
25+
}
26+
```
27+
28+
## 概要
29+
指定したカテゴリのロケールを設定、または現在のロケールを取得する。
30+
31+
-指定できるロケール文字列は[以下のページ](/article/platform/locales.md)である。
32+
+指定できる処理系定義のロケール文字列は[使用できるロケール文字列](/article/platform/locales.md)を参照のこと。
33+
34+
## 引数
35+
- `category`:設定対象のカテゴリ。`LC_ALL`,`LC_CTYPE`などのマクロを使用。
36+
- `locale`:
37+
- * &amp;#34;C&amp;#34;:標準のCロケール
38+
- * &amp;#34;&amp;#34;:環境依存のデフォルトロケール
39+
+ * `&amp;#34;C&amp;#34;`:標準のCロケール
40+
+ * `&amp;#34;&amp;#34;`:環境依存のデフォルトロケール
41+
* `NULL`:現在のロケールを取得するだけ
42+
43+
## 戻り値
44+
成功時は設定されたロケール名(文字列)、失敗時は`NULL`。
45+
46+
+返された文字列をプログラムで変更してはならない。
47+
+
48+
+`setlocale()` を呼び出したスレッドが終了した後、もしくは更に次の `setlocale()` の呼び出しの後に返された文字列を使った時の動作は未定義である。
49+
+
50+
## 例
51+
```cpp example
52+
#include &amp;lt;iostream&amp;gt;
53+
#include &amp;lt;clocale&amp;gt;
54+
55+
-int main(){
56+
+int main() {
57+
// 日本語ロケールに設定
58+
if (!std::setlocale(LC_ALL, &amp;#34;ja_JP.UTF-8&amp;#34;)) {
59+
std::cerr &amp;lt;&amp;lt; &amp;#34;Failed to set locale\n&amp;#34;;
60+
@@ -52,5 +56,5 @@ Numeric locale: ja_JP.UTF-8
61+
```
62+
63+
## 関連項目
64+
-- [ ロケール文字一覧 ](/article/platform/locales.md)
65+
+- [ ロケール文字列一覧 ](/article/platform/locales.md)
66+
- [ `std::locale` ](/reference/locale/locale.md)
67+
&lt;/code&gt;&lt;/pre&gt;</summary>
68+
69+
<author>
70+
<name>K10-K10</name>
71+
<email>keito.tottori@gmail.com</email>
72+
</author>
73+
</entry>
74+
975
<entry>
1076
<title>clocale -- setlocaleへのパスを追加</title>
1177
<link href="https://cpprefjp.github.io/reference/clocale.html"/>
@@ -1417,39 +1483,4 @@ index 000000000..e2934913f
14171483
</author>
14181484
</entry>
14191485

1420-
<entry>
1421-
<title>mblen -- mblenのサンプルコード : ロケールを毎回設定すると重いので文字数計算の外にだした</title>
1422-
<link href="https://cpprefjp.github.io/reference/cstdlib/mblen.html"/>
1423-
<id>0b61755bd12efe68418cb790b84cf00cd8667ea5:reference/cstdlib/mblen.md</id>
1424-
<updated>2025-12-03T10:11:53+09:00</updated>
1425-
1426-
<summary type="html">&lt;pre&gt;&lt;code&gt;diff --git a/reference/cstdlib/mblen.md b/reference/cstdlib/mblen.md
1427-
index 838ee668b..4cdcd924d 100644
1428-
--- a/reference/cstdlib/mblen.md
1429-
+++ b/reference/cstdlib/mblen.md
1430-
@@ -51,7 +51,6 @@ int main() {
1431-
#include &amp;lt;clocale&amp;gt;
1432-
1433-
int count_chars_mblen(const char* s) {
1434-
- std::setlocale(LC_ALL, &amp;#34;ja_JP.UTF-8&amp;#34;);
1435-
int count = 0;
1436-
size_t i = 0;
1437-
while (s[i] != &amp;#39;\0&amp;#39;) {
1438-
@@ -66,6 +65,8 @@ int count_chars_mblen(const char* s) {
1439-
}
1440-
1441-
int main() {
1442-
+ std::setlocale(LC_ALL, &amp;#34;ja_JP.UTF-8&amp;#34;);
1443-
+
1444-
const char* str = &amp;#34;こんにちは世界&amp;#34;;
1445-
std::cout &amp;lt;&amp;lt; &amp;#34;文字列: &amp;#34; &amp;lt;&amp;lt; str &amp;lt;&amp;lt; &amp;#34;\n&amp;#34;;
1446-
std::cout &amp;lt;&amp;lt; &amp;#34;文字数: &amp;#34; &amp;lt;&amp;lt; count_chars_mblen(str) &amp;lt;&amp;lt; &amp;#34;\n&amp;#34;;
1447-
&lt;/code&gt;&lt;/pre&gt;</summary>
1448-
1449-
<author>
1450-
<name>Akira Takahashi</name>
1451-
<email>faithandbrave@gmail.com</email>
1452-
</author>
1453-
</entry>
1454-
14551486
</feed>

gen/pull/1542/sitemap.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20226,7 +20226,7 @@
2022620226

2022720227
<url>
2022820228
<loc>https://cpprefjp.github.io/reference/clocale/setlocale.html</loc>
20229-
<lastmod>2025-12-03T22:38:50+09:00</lastmod>
20229+
<lastmod>2025-12-04T00:13:16+09:00</lastmod>
2023020230
<changefreq>daily</changefreq>
2023120231
<priority>0.7</priority>
2023220232
</url>

0 commit comments

Comments
 (0)