3 ms·
What is the reason for Unicode escapes? It is something legacy from when Unicode was not universally accepted in all systems? Do other programming languages hav
by sebazzz 8y ago
What is the reason for Unicode escapes? It is something legacy from when Unicode was not universally accepted in all systems? Do other programming languages have this?
- chrisseaton 8y agoSeveral programming languages have arcane ways to write what today seem like very normal characters. https://en.wikipedia.org/wiki/Digraphs_and_trigraphs https://en.wikipedia.org/wiki/Digraphs_and_trigraphs For example C has escape sequences for characters as basic as # and [.
- zapzupnz 8y agoDoesn't it have escape sequences for those because they're used in the language's syntax? Stands to reason, or is this even in string literals?
- klodolph 8y agoThey are alternative ways of writing the same character, unlike escape sequences, which have a different meaning from the unescaped version of the same character. For example, in C, I can write: int a<:10:>; Or I can write: int a[10]; They are the same, because <: is exactly the same as [, and :> is exactly the same as ] (except… mercifully, digraphs are not interpreted in strings; trigraphs are another story). However, in a string, the escape sequence \" means something different from ". One is a character in the string, the other ends the string. Digraphs and trigraphs exist because not all keyboards have the corresponding characters, like [ and ]. For example, look at a Swedish keyboard. (You can type [ and ], but not as easily, and maybe not at all on some older keyboards.)