如何判断字符串英文和数字~

yize.link 2009-01-19 03:47:33
不好意思。 之前我知道的,但是那个方法我给忘记了。
在网络上搜索了半个小时了,没有结果。

例如

char = "ahn'124";

如何防止这里 的 '。方法就是判断 unicode码我知道。

但是,如何把 char里面的字符串进行转换unicode,我却忘记了。

有实际点的转换方案码?
...全文
149 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
xiaoyisnail 2009-01-19
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 lbh2001 的回复:]
C/C++ code#include<stdio.h>#include<stdlib.h>#include<windows.h>intmain(void)
{charstr[]="ahn'124";
wchar_t wstr[20]={ L'\0'};//1 库函数if(mbstowcs(wstr, str,sizeof(str)))
{
wprintf(L"%s\n", wstr);
}//2 Windows APIMultiByteToWideChar(CP_ACP,0, str, strlen(str), wstr,sizeof(str));
wprintf(L"%s\n", wstr);return0;
}
[/Quote]

用mbstowcs的话要记得setlocale
lbh2001 2009-01-19
  • 打赏
  • 举报
回复
又忘改了,再贴一次
#include <stdio.h> 
#include <stdlib.h>
#include <windows.h>

int main(void)
{
char str[] = "ahn'124";
wchar_t wstr[20] = { L'\0' };
// 1 库函数
if (mbstowcs(wstr, str, sizeof(str)))
{
wprintf(L"%s\n", wstr);
}
// 2 Windows API
MultiByteToWideChar(CP_ACP, 0, str, strlen(str), wstr, sizeof(wstr));
wprintf(L"%s\n", wstr);

return 0;
}
lbh2001 2009-01-19
  • 打赏
  • 举报
回复
上面有点错误
#include <stdio.h> 
#include <stdlib.h>
#include <windows.h>

int main(void)
{
char str[] = "ahn'124";
wchar_t wstr[20] = { L'\0' };
// 1 库函数
if (mbstowcs(wstr, str, sizeof(str)))
{
wprintf(L"%s\n", wstr);
}
// 2 Windows API
MultiByteToWideChar(CP_ACP, 0, str, strlen(str), wstr, sizeof(str));
wprintf(L"%s\n", wstr);

return 0;
}
lbh2001 2009-01-19
  • 打赏
  • 举报
回复

#include <stdio.h>
#include <stdlib.h>
#include <windows.h>

int main(void)
{
char str[] = "ahn'124";
wchar_t wstr[20] = { L'\0' };
// 1 库函数
if (mbstowcs(wstr, str, sizeof(str)))
{
wprintf(L"%s\n", wstr);
}
// 2 Windows API
MultiByteToWideChar(CP_ACP, 0, str, strlen(str), wstr, sizeof(str));
wprintf(L"%s\n", wstr);

return 0;
}
nullah 2009-01-19
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 xiaoyisnail 的回复:]
isdigit
isalpha
[/Quote]
#include <cctype>
需要的头文件
chenzhp 2009-01-19
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 xiaoyisnail 的回复:]
isdigit
isalpha
[/Quote]
同上
xiaoyisnail 2009-01-19
  • 打赏
  • 举报
回复
isdigit
isalpha

65,211

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧