Long time ago, some really strange characters encodings were used.
For example, a character encoding for the German language DIN 66003
was in use from 1974 to 1999. It was created by modifying the ASCII encoding, namely replacing characters [\]{|}~
with ÄÖÜäöüß
. It was a cool idea as for those days - look, some unecessary brackets were replaced with actual letters of the alphabet!
In order to make it possible to write C++ code on such encodings, there was an ingenious approach - one can write <%
, %>
, <:
, :>
, %:
, %:%:
instead of {
, }
, [
, ]
, #
.
Combining with legal substitutions &&
-> and
, !=
-> not_eq
, etc., this code will compile:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
int main(int argc, char* argv<::>)
<%
// lambda with reference-capture:
auto greet = <:bitand:>(const char* name)
<%
std::cout << "Hello " << name
<< " from " << argv<:0:> << '\n';
%>;
if (argc > 1 and argv<:1:> not_eq nullptr) <%
greet(argv<:1:>);
%> else <%
greet("Anon");
%>
%>
To add more fun, C/C++ has “trigraphs” - one can substitute {
-> ??<
, [
-> ??(
, and so on.