mbstowcs.c

来自「基于4个mips核的noc设计」· C语言 代码 · 共 36 行

C
36
字号
/* * ansi/stdlib/mbstowcs.c * ANSI/ISO 9899-1990, Section 7.10.8.1. * * size_t mbstowcs(wchar_t *pwcs, const char *s, size_t n) * Convert multibyte character string to wide character string. * This uses mbtowc(), thus assuming the encoding used is not state-dependent. */#include <stdlib.h>size_tmbstowcs(wchar_t *pwcs, const char *s, size_t n){	register int count, len;	if (s == NULL)		return 0;		/* encoding is not state-dependent */	count = 0;	while (*s != 0 && count < n) {		len = mbtowc(pwcs++, s, MB_CUR_MAX);		if (len == -1)			return (size_t) -1;	/* invalid */		++count;		s += len;	}	/* Null-terminate the wide string if there is space. */	if (count < n)		*pwcs = (wchar_t) 0;	return count;}/* end of mbstowcs.c */

⌨️ 快捷键说明

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