名稱空間
變體
操作

標準庫標頭檔案 <cwchar>

來自 cppreference.com
 
 
標準庫標頭檔案
演算法
<algorithm>
<numeric>
字串
<cctype>
<cstring>
<cuchar> (C++11)
<cwchar>
<cwctype>
<string_view> (C++17)
<string>
文字處理
<clocale>
<codecvt> (C++11/17/26*)
<locale>
<regex> (C++11)
<text_encoding> (C++26)   
數值
<cfenv> (C++11)
<cmath>
<complex>
<linalg> (C++26)
<numbers> (C++20)
<random> (C++11)
<simd> (C++26)
<valarray>
時間
<chrono> (C++11)
<ctime>
C 相容性
<ccomplex> (C++11/17/20*)
<ciso646> (直到 C++20)
<cstdalign> (C++11/17/20*)
<cstdbool> (C++11/17/20*)
<ctgmath> (C++11/17/20*)
 

此標頭檔案最初是 C 標準庫中的 <wchar.h>

此標頭檔案是空終止 多位元組 字串庫的一部分。它還提供了一些 C 風格的 I/O 函式和從 C 風格日期 的轉換。

目錄

[編輯]

實現定義的空指標常量
(宏常量) [編輯]
WEOF
型別為 std::wint_t 的非字元值,用於指示錯誤
(宏常量)
WCHAR_MIN
wchar_t 的最小有效值
(宏常量)
WCHAR_MAX
wchar_t 的最大有效值
(宏常量)

[編輯] 型別

迭代多位元組字串所需的轉換狀態資訊
(類) [編輯]
sizeof 運算子返回的無符號整型
(typedef) [編輯]
wint_t 可容納任何有效寬字元和至少一個額外值的整型
日曆時間型別
(類) [編輯]

[編輯] 函式

字串操作
將一個寬字串複製到另一個寬字串
(函式) [編輯]
將一定數量的寬字元從一個字串複製到另一個字串
(函式) [編輯]
將一個寬字串的副本追加到另一個寬字串
(函式) [編輯]
將一定數量的寬字元從一個寬字串附加到另一個寬字串
(函式) [編輯]
轉換寬字串,使 wcscmp 產生與 wcscoll 相同的結果
(函式) [編輯]
字串檢查
返回寬字串的長度
(函式) [編輯]
比較兩個寬字串
(函式) [編輯]
比較兩個寬字串中的一定數量的字元
(函式) [編輯]
根據當前語言環境比較兩個寬字串
(函式) [編輯]
在寬字串中查詢寬字元的首次出現
(函式) [編輯]
在寬字串中查詢寬字元的最後一次出現
(函式) [編輯]
返回由另一個位元組字串中找到的字元組成的最大初始段的長度
僅包含在另一個寬字串中找到的寬字元
(函式) [編輯]
返回由另一個位元組字串中找到的字元組成的最大初始段的長度
僅當另一個寬字串中找到寬字元時
(函式) [編輯]
在另一個寬字串中查詢一個寬字串中任意寬字元的首次出現位置
(函式) [編輯]
在一個寬字串中查詢另一個寬字串的首次出現
(函式) [編輯]
在寬字串中查詢下一個標記
(函式) [編輯]
寬字元陣列操作
在兩個不重疊的陣列之間複製一定數量的寬字元
(函式) [編輯]
在兩個可能重疊的陣列之間複製一定數量的寬字元
(函式) [編輯]
比較兩個陣列中一定數量的寬字元
(函式) [編輯]
在寬字元陣列中查詢寬字元的首次出現
(函式) [編輯]
將給定寬字元複製到寬字元陣列中的每個位置
(函式) [編輯]
多位元組/寬字元轉換
檢查 std::mbstate_t 物件是否表示初始移位狀態
(函式) [編輯]
如果可能,將單位元組窄字元加寬為寬字元
(函式) [編輯]
如果可能,將寬字元縮小為單位元組窄字元
(函式) [編輯]
返回下一個多位元組字元的位元組數,給定狀態
(函式) [編輯]
將下一個多位元組字元轉換為寬字元,給定狀態
(函式) [編輯]
將寬字元轉換為其多位元組表示,給定狀態
(函式) [編輯]
將窄多位元組字元字串轉換為寬字串,給定狀態
(函式) [編輯]
將寬字串轉換為窄多位元組字元字串,給定狀態
(函式) [編輯]
輸入/輸出
從檔案流中獲取一個寬字元
(函式) [編輯]
從檔案流中獲取一個寬字串
(函式) [編輯]
向檔案流寫入一個寬字元
(函式) [編輯]
向檔案流寫入一個寬字串
(函式) [編輯]
stdin 讀取寬字元
(函式) [編輯]
stdout 寫入寬字元
(函式) [編輯]
將一個寬字元放回檔案流中
(函式) [編輯]
在寬字元 I/O 和窄字元 I/O 之間切換檔案流
(函式) [編輯]
stdin、檔案流或緩衝區讀取格式化的寬字元輸入
(函式) [編輯]
(C++11)(C++11)(C++11)
stdin、檔案流讀取格式化的寬字元輸入
或使用可變引數列表的緩衝區
(函式) [編輯]
stdout、檔案流或緩衝區列印格式化的寬字元輸出
(函式) [編輯]
stdout、檔案流列印格式化的寬字元輸出
或使用可變引數列表的緩衝區
(函式) [編輯]
字串轉換
std::tm 物件轉換為自定義寬字串文字表示
(函式) [編輯]
將寬字串轉換為整數值
(函式) [編輯]
將寬字串轉換為無符號整數值
(函式) [編輯]
將寬字串轉換為浮點值
(函式) [編輯]

[編輯] 注意

[編輯] 概要

namespace std {
  using size_t =    /* see description */; // freestanding
  using mbstate_t = /* see description */; // freestanding
  using wint_t =    /* see description */; // freestanding
 
  struct tm;
 
  int fwprintf(FILE* stream, const wchar_t* format, ...);
  int fwscanf(FILE* stream, const wchar_t* format, ...);
  int swprintf(wchar_t* s, size_t n, const wchar_t* format, ...);
  int swscanf(const wchar_t* s, const wchar_t* format, ...);
  int vfwprintf(FILE* stream, const wchar_t* format, va_list arg);
  int vfwscanf(FILE* stream, const wchar_t* format, va_list arg);
  int vswprintf(wchar_t* s, size_t n, const wchar_t* format, va_list arg);
  int vswscanf(const wchar_t* s, const wchar_t* format, va_list arg);
  int vwprintf(const wchar_t* format, va_list arg);
  int vwscanf(const wchar_t* format, va_list arg);
  int wprintf(const wchar_t* format, ...);
  int wscanf(const wchar_t* format, ...);
  wint_t fgetwc(FILE* stream);
  wchar_t* fgetws(wchar_t* s, int n, FILE* stream);
  wint_t fputwc(wchar_t c, FILE* stream);
  int fputws(const wchar_t* s, FILE* stream);
  int fwide(FILE* stream, int mode);
  wint_t getwc(FILE* stream);
  wint_t getwchar();
  wint_t putwc(wchar_t c, FILE* stream);
  wint_t putwchar(wchar_t c);
  wint_t ungetwc(wint_t c, FILE* stream);
  double wcstod(const wchar_t* nptr, wchar_t** endptr);
  float wcstof(const wchar_t* nptr, wchar_t** endptr);
  long double wcstold(const wchar_t* nptr, wchar_t** endptr);
  long int wcstol(const wchar_t* nptr, wchar_t** endptr, int base);
  long long int wcstoll(const wchar_t* nptr, wchar_t** endptr, int base);
  unsigned long int wcstoul(const wchar_t* nptr, wchar_t** endptr, int base);
  unsigned long long int wcstoull(const wchar_t* nptr, wchar_t** endptr, int base);
  wchar_t* wcscpy(wchar_t* s1, const wchar_t* s2);                // freestanding
  wchar_t* wcsncpy(wchar_t* s1, const wchar_t* s2, size_t n);     // freestanding
  wchar_t* wmemcpy(wchar_t* s1, const wchar_t* s2, size_t n);     // freestanding
  wchar_t* wmemmove(wchar_t* s1, const wchar_t* s2, size_t n);    // freestanding
  wchar_t* wcscat(wchar_t* s1, const wchar_t* s2);                // freestanding
  wchar_t* wcsncat(wchar_t* s1, const wchar_t* s2, size_t n);     // freestanding
  int wcscmp(const wchar_t* s1, const wchar_t* s2);               // freestanding
  int wcscoll(const wchar_t* s1, const wchar_t* s2);
  int wcsncmp(const wchar_t* s1, const wchar_t* s2, size_t n);    // freestanding
  size_t wcsxfrm(wchar_t* s1, const wchar_t* s2, size_t n);
  int wmemcmp(const wchar_t* s1, const wchar_t* s2, size_t n);    // freestanding
  const wchar_t* wcschr(const wchar_t* s, wchar_t c);             // freestanding
  wchar_t* wcschr(wchar_t* s, wchar_t c);                         // freestanding
  size_t wcscspn(const wchar_t* s1, const wchar_t* s2);           // freestanding
  const wchar_t* wcspbrk(const wchar_t* s1, const wchar_t* s2);   // freestanding
  wchar_t* wcspbrk(wchar_t* s1, const wchar_t* s2);               // freestanding
  const wchar_t* wcsrchr(const wchar_t* s, wchar_t c);            // freestanding
  wchar_t* wcsrchr(wchar_t* s, wchar_t c);                        // freestanding
  size_t wcsspn(const wchar_t* s1, const wchar_t* s2);            // freestanding
  const wchar_t* wcsstr(const wchar_t* s1, const wchar_t* s2);    // freestanding
  wchar_t* wcsstr(wchar_t* s1, const wchar_t* s2);                // freestanding
  wchar_t* wcstok(wchar_t* s1, const wchar_t* s2, wchar_t** ptr); // freestanding
  const wchar_t* wmemchr(const wchar_t* s, wchar_t c, size_t n);  // freestanding
  wchar_t* wmemchr(wchar_t* s, wchar_t c, size_t n);              // freestanding
  size_t wcslen(const wchar_t* s);                                // freestanding
  wchar_t* wmemset(wchar_t* s, wchar_t c, size_t n);              // freestanding
  size_t wcsftime(wchar_t* s, size_t maxsize, const wchar_t* format, const tm* timeptr);
  wint_t btowc(int c);
  int wctob(wint_t c);
 
  // multibyte / wide string and character conversion functions
  int mbsinit(const mbstate_t* ps);
  size_t mbrlen(const char* s, size_t n, mbstate_t* ps);
  size_t mbrtowc(wchar_t* pwc, const char* s, size_t n, mbstate_t* ps);
  size_t wcrtomb(char* s, wchar_t wc, mbstate_t* ps);
  size_t mbsrtowcs(wchar_t* dst, const char** src, size_t len, mbstate_t* ps);
  size_t wcsrtombs(char* dst, const wchar_t** src, size_t len, mbstate_t* ps);
}
 
#define NULL      /* see description */ // freestanding
#define WCHAR_MAX /* see description */ // freestanding
#define WCHAR_MIN /* see description */ // freestanding
#define WEOF      /* see description */ // freestanding

[編輯] 缺陷報告

下列更改行為的缺陷報告追溯地應用於以前出版的 C++ 標準。

缺陷報告 應用於 釋出時的行為 正確的行為
LWG 345 C++98 std::tm 未在 <cwchar> 中提供 已提供