mbtowc

Section: C Library Functions (3)
Updated: 2026-02-08
Index JM Home Page roff page
 

名前

mbtowc - マルチバイト列をワイド文字に変換する  

ライブラリ

標準 C ライブラリ (libc,~-lc)  

書式

#include <stdlib.h>

int mbtowc(size_t size;
           wchar_t *restrict pwc, const char s[restrict size],
           size_t size);
 

説明

The main case for this function is when s is not NULL and pwc is not NULL. In this case, the mbtowc() function inspects at most size bytes of the multibyte string starting at s, extracts the next complete multibyte character, converts it to a wide character and stores it at *pwc. It updates an internal shift state known only to the mbtowc() function. If s does not point to a null byte ('\0'), it returns the number of bytes that were consumed from s, otherwise it returns 0.

If the size bytes starting at s do not contain a complete multibyte character, or if they contain an invalid multibyte sequence, mbtowc() returns -1. This can happen even if size >= MB_CUR_MAX, if the multibyte string contains redundant shift sequences.

s が NULL でなく pwc が NULL の場合は mbtowc() 関数は 上記と同様に動作するが、変換したワイド文字はメモリーには書き込まれない。

A third case is when s is NULL. In this case, pwc and size are ignored. The mbtowc() function resets the shift state, only known to this function, to the initial state, and returns nonzero if the encoding has nontrivial shift state, or zero if the encoding is stateless.  

返り値

s が NULL でなければ mbtowc() 関数は s から消費した バイト数を、s がヌル文字を指している場合はゼロを、 変換に失敗した場合は -1 を返す。

s が NULL ならば mbtowc() 関数は文字符号がシフト状態に依存 していればゼロ以外を、状態によらなければゼロを返す。  

属性

この節で使用されている用語の説明については、 attributes(7) を参照。
インターフェース属性値
mbtowc() Thread safetyMT-Unsafe race
 

バージョン

この関数はマルチスレッドでは安全ではない。 mbrtowc(3) 関数は 同じ機能のより良いインターフェースを提供する。  

標準規格

C11, POSIX.1-2008.  

歴史

POSIX.1-2001, C99.  

注意

mbtowc() の動作は現在のロケールの LC_CTYPE カテゴリーに依存している。  

関連項目

MB_CUR_MAX(3), mblen(3), mbrtowc(3), mbstowcs(3), wcstombs(3), wctomb(3)


 

Index

名前
ライブラリ
書式
説明
返り値
属性
バージョン
標準規格
歴史
注意
関連項目

This document was created by man2html, using the manual pages.