-
Notifications
You must be signed in to change notification settings - Fork 172
<clocale>ライブラリの追加 #1542
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
<clocale>ライブラリの追加 #1542
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.