「cpp/locale/codecvt/length」の版間の差分
提供: cppreference.com
TranslationBot (トーク | 投稿記録) (Translated from the English version using Google Translate) |
細 (1版:Translate from the English version) |
2012年10月30日 (火) 17:33時点における版
![]() |
このページは、Google 翻訳を使って英語版から機械翻訳されました。
翻訳には誤りや奇妙な言い回しがあるかもしれません。文章の上にポインタをおくと、元の文章が見れます。誤りを修正して翻訳を改善する手助けをしてください。翻訳についての説明は、ここをクリックしてください。 |
Defined in header <locale>
|
||
public: int length( stateT& state, |
(1) | |
protected: int do_length( stateT& state, |
(2) | |
パブリックメンバ関数は、最派生クラスのメンバ関数を呼び出し
2) do_length
.Original:
public member function, calls the member function
do_length
of the most derived class.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
せいぜい
externT
[from, from_end)
文字に初期変換状態state
与えmax
によって定義された文字配列、からinternT
文字を変換しようとし、そのような変換が消費してしまうことexternT
文字の数を返します。まるで架空state
出力バッファ用do_in(state, from, from_end, from, to, to+max, to)を実行することにより、[to, to+max)
修正.Original:
attempts to convert the
externT
characters from the character array defined by [from, from_end)
, given initial conversion state state
, to at most max
internT
characters, and returns the number of externT
characters that such conversion would consume. Modifies state
as if by executing do_in(state, from, from_end, from, to, to+max, to) for some imaginary [to, to+max)
output buffer.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
値を返します
externT
によって変換された場合は、いずれかのすべてのdo_in()
文字が消費またはfrom_end-frommax
文字がプロデューサーだったり、変換エラーが発生しました..されるまでに消費されるinternT
文字の数Original:
The number of
externT
characters that would be consumed if converted by do_in()
until either all from_end-from characters were consumed or max
internT
characters were producer, or a conversion error occurred.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
非変換分業std::codecvt<char, char, std::mbstate_t>戻りstd::min(max, from_end-from)
Original:
The non-converting specialization std::codecvt<char, char, std::mbstate_t> returns std::min(max, from_end-from)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
例
Run this code
#include <locale> #include <string> #include <iostream> int main() { // narrow multibyte encoding std::string s = "z\u00df\u6c34\U0001d10b"; // or u8"zß水𝄋" // or "\x7a\xc3\x9f\xe6\xb0\xb4\xf0\x9d\x84\x8b"; std::mbstate_t mb = std::mbstate_t(); std::cout << "Only the first " << std::use_facet<std::codecvt<wchar_t, char, std::mbstate_t>>( std::locale("en_US.utf8") ).length(mb, &s[0], &s[s.size()], 2) << " bytes out of " << s.size() << " would be consumed " " to produce the first 2 characters\n"; }
出力:
Only the first 3 bytes out of 10 would be consumed to produce the first 2 characters