Skip to content

Commit 71ddec2

Browse files
committed
feat(mblen): C規格変更の経緯についての関連項目を追加
1 parent 24e134c commit 71ddec2

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

reference/cstdlib/mblen.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ namespace std {
1818
1919
`n`は解析に使用する最大バイト数を指定する。
2020
21-
エンコーディングの内部状態に関する振る舞いが最近の規格で変更されたことから、
2221
内部状態に依存するエンコーディングを考慮するならば、
2322
特に理由がない限り `std::mblen` ではなく `std::mbstate_t` を受け取る `std::mbrlen` を
2423
新しいコードでは用いるべきである。
24+
エンコーディングの内部状態に関する振る舞いが C11 で変更 (WG14 N1373) されたが、
2525
以前の振る舞いではスレッドセーフではなく、
2626
現在の振る舞いではそもそも内部状態に依存する使い方ができない。
2727
@@ -135,3 +135,14 @@ int main() {
135135
## 関連項目
136136
137137
- [`mbrlen`](../cwchar/mbrlen.md.nolink): `std::mbstate_t` を受け取るスレッドセーフなバージョン
138+
- [WG14 N1373: Wording improvements for mblen, mbtowc, and c16rtomb](https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1373.htm)
139+
- 単なる「表現の改善」としてこの破壊的な変更が実施されたように見える。
140+
- [musl のメーリングリスト - 2019-12-26](https://www.openwall.com/lists/musl/2019/12/26/7) にて Florian Weimer が以下のように指摘している:
141+
"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)."
142+
訳: C11 における mblen の振る舞い変更でも分かるように、C標準化委員会には古い文字コードを使っている人がいないようだ。
143+
- [WG14 N2037: mblen, mbtowc, and wctomb thread-safety](https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2037.htm)
144+
- [WG14 DR498: mblen, mbtowc, and wctomb thread-safety](https://www.open-std.org/jtc1/sc22/wg14/issues/c11c17/issue0498.html)
145+
- [WG14 N2246: Make mblen, mbtowc, and wctomb thread-safe for encodings that are not state-dependent](https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2246.htm)
146+
- [WG14 N2281: Make mblen, mbtowc, and wctomb thread-safe for encodings that are not state-dependent](https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2281.htm)
147+
- [WG14 N2358: No internal state for mblen](https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2358.htm)
148+
- C11 以降もあたかも `mblen` が内部状態を持つかのような記述になっていたのが C23 で修正された。

0 commit comments

Comments
 (0)