mbsinit
From cppreference.net
|
헤더 파일에 정의됨
<wchar.h>
|
||
|
int
mbsinit
(
const
mbstate_t
*
ps
)
;
|
(C95부터) | |
만약
ps
가 null 포인터가 아니라면,
mbsinit
함수는 가리키는
mbstate_t
객체가 초기 변환 상태를 기술하는지 여부를 결정합니다.
목차 |
참고 사항
제로 초기화된 mbstate_t 는 항상 초기 변환 상태를 나타내지만, mbstate_t 의 다른 값들도 초기 변환 상태를 나타낼 수 있습니다.
매개변수
| ps | - | 검사할 mbstate_t 객체에 대한 포인터 |
반환값
0
만약
ps
가 null 포인터가 아니고 초기 변환 상태를 나타내지 않는 경우, 그렇지 않으면 0이 아닌 값.
예제
이 코드 실행
#include <locale.h> #include <string.h> #include <stdio.h> #include <wchar.h> int main(void) { // allow mbrlen() to work with UTF-8 multibyte encoding setlocale(LC_ALL, "en_US.utf8"); // UTF-8 narrow multibyte encoding const char* str = u8"水"; // or u8"\u6c34" or "\xe6\xb0\xb4" static mbstate_t mb; // zero-initialize (void)mbrlen(&str[0], 1, &mb); if (!mbsinit(&mb)) { printf("After processing the first 1 byte of %s,\n" "the conversion state is not initial\n\n", str); } (void)mbrlen(&str[1], strlen(str), &mb); if (mbsinit(&mb)) { printf("After processing the remaining 2 bytes of %s,\n" "the conversion state is initial conversion state\n", str); } }
출력:
After processing the first 1 byte of 水, the conversion state is not initial After processing the remaining 2 bytes of 水, the conversion state is initial conversion state
참고문헌
- C17 표준 (ISO/IEC 9899:2018):
-
- 7.29.6.2.1 mbsinit 함수 (p: 322)
- C11 표준 (ISO/IEC 9899:2011):
-
- 7.29.6.2.1 mbsinit 함수 (p: 441-442)
- C99 표준 (ISO/IEC 9899:1999):
-
- 7.24.6.2.1 mbsinit 함수 (p: 387-388)
참고 항목
|
(C95)
|
멀티바이트 문자 문자열을 순회하는 데 필요한 변환 상태 정보
(클래스) |
|
C++ documentation
for
mbsinit
|
|