|
188 | 188 |
|
189 | 189 | <p class="text-right"><small> |
190 | 190 | 最終更新日時(UTC): |
191 | | - <span itemprop="datePublished" content="2026-01-06T05:35:23"> |
192 | | - 2026年01月06日 05時35分23秒 |
| 191 | + <span itemprop="datePublished" content="2026-01-06T06:37:48"> |
| 192 | + 2026年01月06日 06時37分48秒 |
193 | 193 | </span> |
194 | 194 | <br/> |
195 | 195 | <span itemprop="author" itemscope itemtype="http://schema.org/Person"> |
@@ -223,10 +223,10 @@ <h2>概要</h2> |
223 | 223 | <p>先頭以外の文字に関するバイト数は計算されない。</p> |
224 | 224 | <p>この関数は現在のロケールカテゴリー <code>LC_CTYPE</code> に依存してマルチバイト文字を解釈する。</p> |
225 | 225 | <p><code>n</code>は解析に使用する最大バイト数を指定する。</p> |
226 | | -<p>エンコーディングの内部状態に関する振る舞いが最近の規格で変更されたことから、 |
227 | | -内部状態に依存するエンコーディングを考慮するならば、 |
| 226 | +<p>内部状態に依存するエンコーディングを考慮するならば、 |
228 | 227 | 特に理由がない限り <code>std::mblen</code> ではなく <code>std::mbstate_t</code> を受け取る <code>std::mbrlen</code> を |
229 | 228 | 新しいコードでは用いるべきである。 |
| 229 | +エンコーディングの内部状態に関する振る舞いが C11 で変更 (WG14 N1373) されたが、 |
230 | 230 | 以前の振る舞いではスレッドセーフではなく、 |
231 | 231 | 現在の振る舞いではそもそも内部状態に依存する使い方ができない。</p> |
232 | 232 | <h3>C11, C++17, POSIX.1-2024 以降</h3> |
@@ -322,6 +322,21 @@ <h4>出力例</h4> |
322 | 322 | <h2>関連項目</h2> |
323 | 323 | <ul> |
324 | 324 | <li><code><span href="https://cpprefjp.github.io/reference/cwchar/mbrlen.md.nolink">mbrlen</span></code>: <code>std::mbstate_t</code> を受け取るスレッドセーフなバージョン</li> |
| 325 | +<li><a href="https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1373.htm" target="_blank">WG14 N1373: Wording improvements for mblen, mbtowc, and c16rtomb</a><ul> |
| 326 | +<li>単なる「表現の改善」としてこの破壊的な変更が実施されたように見える。</li> |
| 327 | +<li><a href="https://www.openwall.com/lists/musl/2019/12/26/7" target="_blank">musl のメーリングリスト - 2019-12-26</a> にて Florian Weimer が以下のように指摘している: |
| 328 | + "actual users of the interfaces with legacy charsets do not seem to be represented on the standards committee anymore (see the mblen behavioral change in C11 as evidence supporting this theory)." |
| 329 | + 訳: C11 における mblen の振る舞い変更でも分かるように、C標準化委員会には古い文字コードを使っている人がいないようだ。</li> |
| 330 | +</ul> |
| 331 | +</li> |
| 332 | +<li><a href="https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2037.htm" target="_blank">WG14 N2037: mblen, mbtowc, and wctomb thread-safety</a><ul> |
| 333 | +<li><a href="https://www.open-std.org/jtc1/sc22/wg14/issues/c11c17/issue0498.html" target="_blank">WG14 DR498: mblen, mbtowc, and wctomb thread-safety</a></li> |
| 334 | +<li><a href="https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2246.htm" target="_blank">WG14 N2246: Make mblen, mbtowc, and wctomb thread-safe for encodings that are not state-dependent</a></li> |
| 335 | +<li><a href="https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2281.htm" target="_blank">WG14 N2281: Make mblen, mbtowc, and wctomb thread-safe for encodings that are not state-dependent</a></li> |
| 336 | +<li><a href="https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2358.htm" target="_blank">WG14 N2358: No internal state for mblen</a></li> |
| 337 | +<li>C11 以降もあたかも <code>mblen</code> が内部状態を持つかのような記述になっていたのが C23 で修正された。</li> |
| 338 | +</ul> |
| 339 | +</li> |
325 | 340 | </ul></div> |
326 | 341 |
|
327 | 342 | </div> |
|
0 commit comments