mbtowc.c

来自「标准c库代码,可以应用于各个系统提供了大量的基本函数」· C语言 代码 · 共 58 行

C
58
字号
/*FUNCTION<<mbtowc>>---minimal multibyte to wide char converterINDEX	mbtowcANSI_SYNOPSIS	#include <stdlib.h>	int mbtowc(wchar_t *<[pwc]>, const char *<[s]>, size_t <[n]>);TRAD_SYNOPSIS	#include <stdlib.h>	int mbtowc(<[pwc]>, <[s]>, <[n]>)	wchar_t *<[pwc]>;	const char *<[s]>;	size_t <[n]>;DESCRIPTIONThis is a minimal ANSI-conforming implementation of <<mbtowc>>.  Theonly ``multi-byte character sequences'' recognized are single bytes,and they are ``converted'' to themselves.Each call to <<mbtowc>> copies one character from <<*<[s]>>> to<<*<[pwc]>>>, unless <[s]> is a null pointer.In this implementation, the argument <[n]> is ignored.RETURNSThis implementation of <<mbtowc>> returns <<0>> if<[s]> is <<NULL>>; it returns <<1>> otherwise (reporting the length ofthe character ``sequence'' used).PORTABILITY<<mbtowc>> is required in the ANSI C standard.  However, the preciseeffects vary with the locale.<<mbtowc>> requires no supporting OS subroutines.*/#include <stdlib.h>int_DEFUN (mbtowc, (pwc, s, n),        wchar_t *pwc _AND        const char *s _AND        size_t n){        if (s == NULL)                return 0;        if (n == 0)                return -1;        if (pwc)                *pwc = (wchar_t) *s;        return (*s != '\0');}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?