c - isLetter 在 C 中带有重音字符

标签 c testing char diacritics letter

我想创建(或找到)一个 C 函数来检查一个字符 c 是否是一个字母... 当然,我可以轻松地为 a-z 和 A-Z 执行此操作。

但是如果测试 c == á,ã,ô,ç,ë 等我会得到一个错误

可能那些特殊字符存储在多个字符...

我想知道: 这些特殊字符是如何存储的,我的函数需要接收哪些参数,以及如何接收? 我还想知道是否有任何标准函数已经执行此操作。

最佳答案

我认为您正在寻找 iswalpha() 例程:

   #include <wctype.h>

   int iswalpha(wint_t wc);

DESCRIPTION
   The iswalpha() function is the wide-character equivalent of
   the isalpha(3) function.  It tests whether wc is a wide
   character belonging to the wide-character class "alpha".

它确实依赖于当前 locale(7)LC_CTYPE,因此它在应该同时正确处理多种类型输入的程序中的使用可能不会成为理想。

关于c - isLetter 在 C 中带有重音字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5604917/

相关文章:

c - 如何复制具有 const unsigned char * 类型的值?

c - C-搜索中的二叉搜索树如果未找到值则无法返回消息

symfony - Silex - 从测试中分派(dispatch)时不执行监听器

C++如何测试函数使其抛出错误?

c++ - 直接将通过函数传递的 const char* 文本转换为字符 vector

c++ - UTF-8 char * 到 CString 的转换

c - 测试.c :51:4: error: incompatible types when assigning to type ‘blk from type ‘void *’

c - C 预处理器的任何选项只能扩展特殊宏?

c - 在 Solaris 中用字符串中的前导零填充有效,但在 RHEL 中无效

php - 您如何有效地在本地开发/测试然后在生产服务器上启动?