I've recently spent a significant amount of time debugging a problem with a string inside my code.
This produced an error:
"root:password@tcp(127.0.0.1:3306)/employees?readTimeout=15m"
This worked fine:
"root:password@tcp(127.0.0.1:3306)/employees?readTimeout=15m"
As you can see the strings look exactly the same, but when printed out in binary format:
First string:
[114 111 111 116 58 112 97 115 115 119 111 114 100 64 116 99 112 40 49 50 55 46 48 46 48 46 49 58 51 51 48 54 41 47 101 109 112 108 111 121 101 101 115 63 114 101 97 100 84 105 109 101 111 117 116 61 49 53 109]
Second string:
[114 111 111 116 58 112 97 115 115 119 111 114 100 64 116 99 112 40 49 50 55 46 48 46 48 46 49 58 51 51 48 54 41 47 101 109 112 108 111 121 101 101 115 63 114 101 97 100 84 105 109 101 111 117 116 61 49 53 109 226 128 140 226 128 139]
The second string happens to have extra two invisible Unicode characters at the end 226 128 140 226 128 139
that represent ZERO WIDTH NON-JOINER
and ZERO WIDTH SPACE
.
As it turns out, Stack Overflow inserts invisible characters inside long code comments.
When writing a comment like this:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
What really happens under the hood is this:
[97 97 97 97 97 97 97 97 97 97 97 97 97 97 97 97 97 97 97 97 226 128 140 226 128 139 97 97 97 97 97 97 97 97 97 97 97 97 97 97 97 97 97 97 97 97 226 128 140 226 128 139 97 97 97 97 97 97 97 97 97 97 97 97 97 97 97 97 97 97 97 97 226 128 140 226 128 139 97 97 97 97 97 97 97 97 97 97 97 97 97 97 97 97 97 97 97 97 226 128 140]
My question is, why does Stack Overflow do this?
Why is inserting invisible characters into code snippets and effectively creating debugging nightmares considered a good solution?
<wbr>
tags instead though<wbr>
is not supported in Internet Explorer.wordbreak:break-all
word-break: break-all
). Even works on IE8.