Determines whether a particular character is a ASCII character.
int __isascii(
int c
);
int iswascii(
wint_t c
);
Test program:
#include "stdafx.h"
#include "ctype.h"
#include "locale.h"
#include "stdio.h"
void CheckCharAndPrint(char acChar)
{
if(__isascii(acChar))
{
printf("char %c is a ascii char.\n",acChar);
}
else
{
// 此处无法正常输出中文,没有深入研究了
printf("char %c is not a ascii char.\n",acChar);
}
}
void CheckWCharAndPrint(wchar_t awcChar)
{
if(iswascii(awcChar))
{
wprintf(L"wchar %c is a ascii char.\n",awcChar);
}
else
{
setlocale(LC_ALL,"");
wprintf(L"wchar %c is not a ascii char.\n",awcChar);
}
}
int _tmain(int argc, _TCHAR* argv[])
{
char lcC = 'a';
char lcD = '中';
CheckCharAndPrint(lcC);
CheckCharAndPrint(lcD);
wchar_t lwcC = L'a';
wchar_t lwcD = L'中';
CheckWCharAndPrint(lwcC);
CheckWCharAndPrint(lwcD);
return 0;
}
Description
__isascii is a special function because it starts with two front underscores. This is not uncommon in C language. (at least I see less)
This function should not belong to the standard library function, which is not described in the C language reference in "Tcpl", but is available in GCC. In other words, Linux can also use this function normally.
Iswascii the wide-byte version of this __isascii function, like many wide-byte versions of functions, this function belongs to Ms itself, so. Linux can not use this function, to use, you can only achieve ROM.