[晕] 居然还有这种东西:C++ Trigraph
Posted by bianbian on 2007-08-01 15:34
本文Tags: Trigraph
听说为了照顾某些键盘坏了又换不起的,可以使用这种3字符的串来代替一些特殊字符,preprocess的时候会替换掉:
#: ??=
\: ??/
^: ??’
[: ??(
]: ??)
{: ??<
}: ??>
|: ??!
~: ??-
于是程序就这样了:
- //: S03:trigraph.cpp
- ??=include <iostream>
- int main(int argc, char* argv??(??)) ??<
- using namespace std;
- unsigned int n;
- if (argc != 2 ??!??! (n = atoi(argv??(1??))) <= 0)
- return 1;
- cout << ??-(n ??' 0xf0f0) << '??/n';
- return 0;
- ??>
我就奇怪了,键盘换不起,眼睛换换就那么便宜吗?
标签: Trigraph遵守创作共用协议,转载请链接形式注明来自http://bianbian.org 做人要厚道
August 3rd, 2007 at 09:48:44
故意用来混淆代码的吧……
August 7th, 2007 at 04:51:18
NO!
显然不是为键盘坏了准备的,你怎么知道别人坏的是哪个键呢?
引入trigraph的原因是字符编码问题。iso646规定说各国可以用自己国家的一些符号替换掉ASCII里的”{”"}”"[”"]”等,这样问题就来了。那些字符明明不是ASCII,但仍然可以用到程序中,甚至可能没错,但程序读起来明显就费劲了。为了照顾这种情况,C/C++语言标准才考虑用trigraph来把它们给替换掉。