设为首页 加入收藏

TOP

C语言学习趣事_MSCRT_IO_SourceFile (七)
2014-11-24 00:40:18 来源: 作者: 【 】 浏览:256
Tags:语言学习 趣事 _MSCRT_IO_SourceFile
o multibyte character */
textlen = wctomb(buffer.sz, wchar);

/* check that conversion was successful */
if (textlen < 0)
no_output = 1;
}
else
{
/* format multibyte character */
/* this is an extension of ANSI */
unsigned short temp;
temp = (unsigned short) get_int_arg(&argptr);
#ifdef _OUT
if (isleadbyte(temp >> 8))
{
buffer.sz[0] = temp >> 8;
buffer.sz[1] = temp & 0x00ff;
textlen = 2;
}
else
#endif /* _OUT */
{
buffer.sz[0] = (char) temp;
textlen = 1;
}
}
text.sz = buffer.sz;
#endif /* WPRFLAG */
}
break;

#if defined(_WIN32_) && !defined(_DOSX32_) /* UNDONE: NT hack */
case _T('Z'): {
/* print a Counted String

int i;
char *p; /* temps */
struct string {
short Length;
short MaximumLength;
char *Buffer;
} *pstr;

pstr = get_ptr_arg(&argptr);
if (pstr == NULL || pstr->Buffer == NULL) {
/* null ptr passed, use special string */
text.sz = __nullstring;
textlen = strlen(text.sz);
} else {
if (flags & FL_WIDECHAR) {
text.wz = (wchar_t *)pstr->Buffer;
textlen = pstr->Length / sizeof(wchar_t);
bufferiswide = 1;
} else {
bufferiswide = 0;
text.sz = pstr->Buffer;
textlen = pstr->Length;
}
}
}
break;
#endif

case _T('S'): /* ISO wide character string */
#ifndef WPRFLAG
if (!(flags & (FL_SHORT|FL_LONG|FL_WIDECHAR)))
flags |= FL_WIDECHAR;
#else
if (!(flags & (FL_SHORT|FL_LONG|FL_WIDECHAR)))
flags |= FL_SHORT;
#endif
case _T('s'): {
/* print a string -- */
/* ANSI rules on how much of string to print: */
/* all if precision is default, */
/* min(precision, length) if precision given. */
/* prints '(null)' if a null string is passed */

int i;
char *p; /* temps */
wchar_t *pwch;

/* At this point it is tempting to use strlen(), but */
/* if a precision is specified, we're not allowed to */
/* scan past there, because there might be no null */
/* at all. Thus, we must do our own scan. */

i = (precision == -1) INT_MAX : precision;
text.sz = get_ptr_arg(&argptr);

/* UNDONE: handle '#' case properly */
/* scan for null upto i characters */
#ifdef WPRFLAG
if (flags & FL_SHORT)
{
if (text.sz == NULL) /* NULL passed, use special string */
text.sz = __nullstring;
p = text.sz;
for (textlen=0; textlen {
if (isleadbyte((int)*p))
++p;
++p;
}
/* textlen now contains length in multibyte chars */
}
else
{
if (text.wz == NULL) /* NULL passed, use special string */
text.wz = __wnullstring;
bufferiswide = 1;
pwch = text.wz;
while (i-- && *pwc
首页 上一页 4 5 6 7 8 9 10 下一页 尾页 7/12/12
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇STL 应用之set 下一篇快速计算32位数中1的位数

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: