cplusplus
.com
教程
參考
文章
論壇
C++
教程
參考
文章
論壇
參考
C 庫
<cassert> (assert.h)
<cctype> (ctype.h)
<cerrno> (errno.h)
C++11
<cfenv> (fenv.h)
<cfloat> (float.h)
C++11
<cinttypes> (inttypes.h)
<ciso646> (iso646.h)
<climits> (limits.h)
<clocale> (locale.h)
<cmath> (math.h)
<csetjmp> (setjmp.h)
<csignal> (signal.h)
<cstdarg> (stdarg.h)
C++11
<cstdbool> (stdbool.h)
<cstddef> (stddef.h)
C++11
<cstdint> (stdint.h)
<cstdio> (stdio.h)
<cstdlib> (stdlib.h)
<cstring> (string.h)
C++11
<ctgmath> (tgmath.h)
<ctime> (time.h)
C++11
<cuchar> (uchar.h)
<cwchar> (wchar.h)
<cwctype> (wctype.h)
容器
C++11
<array>
<deque>
C++11
<forward_list>
<list>
<map>
<queue>
<set>
<stack>
C++11
<unordered_map>
C++11
<unordered_set>
<vector>
輸入/輸出
<fstream>
<iomanip>
<ios>
<iosfwd>
<iostream>
<istream>
<ostream>
<sstream>
<streambuf>
多執行緒
C++11
<atomic>
C++11
<condition_variable>
C++11
<future>
C++11
<mutex>
C++11
<thread>
其他
<algorithm>
<bitset>
C++11
<chrono>
C++11
<codecvt>
<complex>
<exception>
<functional>
C++11
<initializer_list>
<iterator>
<limits>
<locale>
<memory>
<new>
<numeric>
C++11
<random>
C++11
<ratio>
C++11
<regex>
<stdexcept>
<string>
C++11
<system_error>
C++11
<tuple>
C++11
<type_traits>
C++11
<typeindex>
<typeinfo>
<utility>
<valarray>
<cstdlib> (stdlib.h)
函式
C++11
_Exit
abort
abs
C++11
at_quick_exit
atexit
atof
atoi
atol
C++11
atoll
bsearch
calloc
div
exit
free
getenv
labs
ldiv
C++11
llabs
C++11
lldiv
malloc
mblen
mbstowcs
mbtowc
qsort
C++11
quick_exit
rand
realloc
srand
strtod
C++11
strtof
strtol
C++11
strtold
C++11
strtoll
strtoul
C++11
strtoull
system
wcstombs
wctomb
函式 (非標準)
itoa
型別
div_t
ldiv_t
C++11
lldiv_t
size_t
宏常量
EXIT_FAILURE
EXIT_SUCCESS
MB_CUR_MAX
NULL
RAND_MAX
參考
<cstdlib>
mbstowcs
函式
<cstdlib>
mbstowcs
size_t mbstowcs (wchar_t* dest, const char* src, size_t max);
將多位元組字串轉換為寬字元字串
將
src
指向的多位元組字元序列轉換為等效的寬字元序列(儲存在
dest
指向的陣列中),直到轉換了
max
個寬字元,或者直到遇到多位元組字元序列
src
中的空字元(該空字元也會被轉換並存儲,但在函式返回的長度中不計)。
如果成功轉換了
max
個字元,則儲存在
dest
中的結果字串將不以空字元結尾。
此函式的行為取決於所選
C locale
的
LC_CTYPE
類別。
引數
dest
指向一個足夠大的
wchar_t
元素陣列的指標,該陣列可以容納結果序列(最多
max
個寬字元)。
src
包含要解釋的多位元組字元的 C 字串。
多位元組字元序列應以初始移位狀態開始。
max
要寫入
dest
的
wchar_t
字元的最大數量。
size_t
是一個無符號整數型別。
返回值
寫入
dest
的寬字元數量,不包括最終的*終止空字元*。
如果遇到無效的多位元組字元,則返回
(
size_t
)-1
。
請注意,
size_t
是無符號整數型別,因此返回的任何值都不會小於零。
資料競爭
該函式會訪問
src
指向的陣列,並修改
dest
指向的陣列。
該函式還可能訪問和修改內部狀態物件,如果實現使用了靜態物件(請參閱
mbsrtowcs
以瞭解可使用外部狀態物件的替代方案),這可能導致併發呼叫此函式時出現數據競爭。
併發地更改 locale 設定也可能引入資料競爭。
異常 (C++)
無丟擲保證:
此函式不會丟擲異常。
如果
dest
指向的陣列不足以容納轉換後的序列,或者
src
不是以空字元結尾或不包含足夠的位元組來生成
max
個寬字元(或者它沒有以初始移位狀態開始),則會導致*未定義行為*。
另見
mblen
獲取多位元組字元的長度
(函式)
mbtowc
將多位元組序列轉換為寬字元
(函式)
wcstombs
將寬字串轉換為多位元組字串
(函式)