Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
104 views
in Technique[技术] by (71.8m points)

c++ - Are digraphs and trigraphs in use today?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I don't know for sure, but you're most likely to find digraphs and trigraphs being used in IBM mainframe environments. The EBCDIC character set doesn't include some characters that are required for C.

The other justification for digraphs and trigraphs, 7-bit ASCII-ish character sets that replace some punctuation characters with accented letters, is probably less relevant today.

Outside such environments, I suspect that trigraphs are more commonly used by mistake than deliberately, as in:

puts("What happened??!");

For reference, trigraphs were introduced in the 1989 ANSI C standard (which essentially became the 1990 ISO C standard). They are:

??= #     ??) ]     ??! |
??( [     ??' ^     ??> }
??/      ??< {     ??- ~

The replacements occur anywhere in source code, including comments and string literals.

Digraphs are alternate spellings of certain tokens, and do not affect comments or literals:

<: [      :>   ]
<% {      %>   }
%: #      %:%: ##

Digraphs were introduced by the 1995 amendment to the 1990 ISO C standard.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...