C 中的非 ASCII 字符 [英] Non-ASCII characters in C

查看:34
本文介绍了C 中的非 ASCII 字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在查看 google go 的运行时源代码(位于 https://go.googlecode.com/hg/src/pkg/runtime/ ),似乎他们的函数名称使用了一个特殊字符, · .(例如在 https://go.googlecode.com/hg/src/pkg/runtime/cgocall.c).这是否被主要编译器接受?它不是 ANSI C,是吗?还是只是一些宏观魔术?

I was looking at google go's runtime source code (at https://go.googlecode.com/hg/src/pkg/runtime/ ), and it seems they use a special character for their function names, · . (Look for example at https://go.googlecode.com/hg/src/pkg/runtime/cgocall.c ). Is this accepted across major compilers? It's not ANSI C, is it? Or is it just some macro magic?

谢谢!

推荐答案

C90 不允许在标识符中添加额外的字符(超过基本字符集中的字符),C99 允许(都具有通用字符语法——uXXXX 和UXXXXXXXX -- 以及实现定义的其他字符集).

C90 doesn't allow additional character in identifier (over those in the basic characters set), C99 do (both with the universal character syntax -- uXXXX and UXXXXXXXX -- and an implementation defined set of other characters).

C99 中的 6.4.2.1/1:

6.4.2.1/1 in C99:

identifier:
    identifier-nondigit
    identifier identifier-nondigit
    identifier digit
identifier-nondigit:
    nondigit
    universal-character-name
    other implementation-defined characters
nondigit: one of
    _ a b c d e f g h i j k l m
    n o p q r s t u v w x y z
    A B C D E F G H I J K L M
    N O P Q R S T U V W X Y Z
digit: one of
    0 1 2 3 4 5 6 7 8 9

我不知道 C 实现对它的支持有多好,我知道 Plan9 C 编译器 可以在标准化之前处理其他字符.

I don't know how well it is supported by C implementations, I know that Plan9 C compiler could handle other characters before it was standardized.

这篇关于C 中的非 ASCII 字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆