Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@
| `<cinttypes>` | 固定精度整数のための書式指定マクロ | C++11 (C99) |
| `<ciso646>` | `&&`に対する別名`and`のような、各種演算子に対するマクロを定義する。<br/> ただしC++ではこれらの別名はキーワードとして定義されるため、このヘッダでは何も定義されない。 | C++20で削除 |
| [`<climits>`](/reference/climits.md) | 整数型の最小値、最大値を表すマクロ | |
| `<clocale>` | ロケール | |
| [`<clocale>`](/reference/clocale.md) | ロケール | |
| [`<cmath>`](/reference/cmath.md) | 数学関数 | |
| `<csetjmp>` | ジャンプ処理 | |
| `<csignal>` | シグナル | |
Expand Down
35 changes: 35 additions & 0 deletions reference/clocale.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# clocale
* clocale[meta header]

`<clocale>`ヘッダでは、ローカライゼーション(地域化)に関するクラス・関数を定義する。

これらの機能は基本的には、`std`名前空間に属することを除いてC言語の標準ライブラリ`<locale.h>`ヘッダと同じである。

## マクロ

| 名前 | 説明 | 対応バージョン |
| ------------- | ----------------------------------------- | ------- |
| [`NULL`](/reference/cstddef/null.md) | ヌルポインタ定数に展開されるマクロ | |
| `LC_ALL` | すべてのロケールカテゴリを一括指定するための定数 | |
| `LC_COLLATE` | 文字列の照合(比較)規則に関するロケールカテゴリ | |
| `LC_CTYPE` | 文字分類(大文字/小文字、数字、空白など)やマルチバイト文字の扱いに関するカテゴリ | |
| `LC_MONETARY` | 通貨表記に関するロケールカテゴリ | |
| `LC_NUMERIC` | 数値表記に関するロケールカテゴリ(小数点記号など) | |
| `LC_TIME` | 日付および時刻表記に関するロケールカテゴリ | |

## 構造体
| 名前 | 説明 | 対応バージョン |
| ------------- | ----------------------------------------- | ------- |
| `lconv` | 数値・通貨表示の書式設定をまとめた型 | |

## 関数
| 名前 | 説明 | 対応バージョン |
| ------------- | ----------------------------------------- | ------- |
| [`setlocale`](/reference/clocale/setlocale.md) | ロケールを変更、または現在のロケールを取得する。 | |
| `localeconv` | 現在のロケールに応じた数値・通貨表記情報を取得する。 | |

## 関連項目
- [`locale`](locale.md)

## 参照
[Synopses for the C library](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0175r1.html)
65 changes: 65 additions & 0 deletions reference/clocale/setlocale.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# setlocale
* clocale[meta header]
* std[meta namespace]
* function[meta id-type]

```cpp
namespace std {
char* setlocale(int category, const char* locale);
}
```

## 概要
指定したカテゴリのロケールを設定、または現在のロケールを取得する。

指定できる処理系定義のロケール文字列は[使用できるロケール文字列](/article/platform/locales.md)を参照のこと。

この関数の呼び出しは他スレッドにおける `setlocale()` または現在のロケールを使用する他の関数の呼び出しとデータ競合の可能性がある。

プログラム開始時の現在のロケールは `std::setlocale(LC_ALL, "C");` が呼び出されたのと同じ状態に初期化される。

## 引数
- `category`:設定対象のカテゴリ。`LC_ALL`,`LC_CTYPE`などのマクロを使用。
- `locale`:
* `"C"`:標準のCロケール
* `""`:環境依存のデフォルトロケール
* `NULL`:現在のロケールを取得するだけ
* 処置系定義の文字列

## 戻り値
成功時は設定されたロケール名(文字列)、失敗時は`NULL`。

返された文字列をプログラムで変更してはならない。

`setlocale()` を呼び出したスレッドが終了した後、もしくは更に次の `setlocale()` の呼び出しの後に返された文字列を使った時の動作は未定義である。

## 例
```cpp example
#include <iostream>
#include <clocale>

int main() {
// 日本語ロケールに設定
if (!std::setlocale(LC_ALL, "ja_JP.UTF-8")) {
std::cerr << "Failed to set locale\n";
return 1;
}

// 現在の全カテゴリのロケールを取得
std::cout << "Current locale: " << std::setlocale(LC_ALL, NULL) << "\n";

// 数値カテゴリだけ確認
std::cout << "Numeric locale: " << std::setlocale(LC_NUMERIC, NULL) << "\n";
}

```

### 出力
```
Current locale: ja_JP.UTF-8
Numeric locale: ja_JP.UTF-8
```

## 関連項目
- [ ロケール文字列一覧 ](/article/platform/locales.md)
- [ `std::locale` ](/reference/locale/locale.md)
2 changes: 1 addition & 1 deletion reference/cstdlib/mb_cur_max.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Locale: ja_JP.UTF-8, MB_CUR_MAX: 6

## 関連項目
- [`MB_LEN_MAX`](/reference/climits/mb_len_max.md): 全ロケールでのマルチバイト文字の最大バイト数
- `setlocale`: ロケールを変更する
- [`setlocale`](/reference/clocale/setlocale.md): ロケールを変更する

## 参照
- [mb_cur_max(3) - Linux man page](https://linux.die.net/man/3/mb_cur_max)
2 changes: 1 addition & 1 deletion reference/string/stod.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace std {
- Clang (libc++) 3.3では、この関数の呼び出し前後で`errno`の値は変化しない。

### グローバルロケールの影響
この関数は、`setlocale()`関数により挙動が変化する。
この関数は、[`setlocale()`](/reference/clocale/setlocale.md)関数により挙動が変化する。

- `strtod()`関数での文字列先頭の空白を読み飛ばす処理に、`<cctype>`の`isspace()`関数が使用される。
- 小数点記号は`LC_NUMERIC`で指定されたものが使用される。
Expand Down
2 changes: 1 addition & 1 deletion reference/string/stof.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace std {
- Clang (libc++) 3.3では、この関数の呼び出し前後で`errno`の値は変化しない。

### グローバルロケールの影響
この関数は、`setlocale()`関数により挙動が変化する。
この関数は、[`setlocale()`](/reference/clocale/setlocale.md)関数により挙動が変化する。

- `strtof()`関数での文字列先頭の空白を読み飛ばす処理に、`<cctype>`の`isspace()`関数が使用される。
- 小数点記号は`LC_NUMERIC`で指定されたものが使用される。
Expand Down
2 changes: 1 addition & 1 deletion reference/string/stoi.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ namespace std {
- Clang (libc++) 3.3では、この関数の呼び出し前後で`errno`の値は変化しない。

### グローバルロケールの影響
この関数は、`setlocale()`関数により挙動が変化する。
この関数は、[`setlocale()`](/reference/clocale/setlocale.md)関数により挙動が変化する。

`strtol()`関数での文字列先頭の空白を読み飛ばす処理に、`<cctype>`の`isspace()`関数が使用されるためである。

Expand Down
2 changes: 1 addition & 1 deletion reference/string/stol.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ namespace std {
- Clang (libc++) 3.3では、この関数の呼び出し前後で`errno`の値は変化しない。

### グローバルロケールの影響
この関数は、`setlocale()`関数により挙動が変化する。
この関数は、[`setlocale()`](/reference/clocale/setlocale.md)関数により挙動が変化する。

`strtol()`関数での文字列先頭の空白を読み飛ばす処理に、`<cctype>`の`isspace()`関数が使用されるためである。

Expand Down
2 changes: 1 addition & 1 deletion reference/string/stold.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace std {
- Clang (libc++) 3.3では、この関数の呼び出し前後で`errno`の値は変化しない。
### グローバルロケールの影響
この関数は、`setlocale()`関数により挙動が変化する。
この関数は、[`setlocale()`](/reference/clocale/setlocale.md)関数により挙動が変化する。
- `strtold()`関数での文字列先頭の空白を読み飛ばす処理に、`<cctype>`の`isspace()`関数が使用される。
- 小数点記号は`LC_NUMERIC`で指定されたものが使用される。
Expand Down
2 changes: 1 addition & 1 deletion reference/string/stoll.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ namespace std {
- Clang (libc++) 3.3では、この関数の呼び出し前後で`errno`の値は変化しない。
### グローバルロケールの影響
この関数は、`setlocale()`関数により挙動が変化する。
この関数は、[`setlocale()`](/reference/clocale/setlocale.md)関数により挙動が変化する。
`strtoll()`関数での文字列先頭の空白を読み飛ばす処理に、`<cctype>`の`isspace()`関数が使用されるためである。
Expand Down
2 changes: 1 addition & 1 deletion reference/string/stoul.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ namespace std {
- Clang (libc++) 3.3では、この関数の呼び出し前後で`errno`の値は変化しない。
### グローバルロケールの影響
この関数は、`setlocale()`関数により挙動が変化する。
この関数は、[`setlocale()`](/reference/clocale/setlocale.md)関数により挙動が変化する。
`strtoul()`関数での文字列先頭の空白を読み飛ばす処理に、`<cctype>`の`isspace()`関数が使用されるためである。
Expand Down
2 changes: 1 addition & 1 deletion reference/string/stoull.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ namespace std {
- Clang (libc++) 3.3では、この関数の呼び出し前後で`errno`の値は変化しない。

### グローバルロケールの影響
この関数は、`setlocale()`関数により挙動が変化する。
この関数は、[`setlocale()`](/reference/clocale/setlocale.md)関数により挙動が変化する。

`strtoull()`関数での文字列先頭の空白を読み飛ばす処理に、`<cctype>`の`isspace()`関数が使用されるためである。

Expand Down