The specification for the Go language is very clear that rune literals and string literals cannot include surrogate halves, and gives as examples '\uDFFF' and "\uD800" that it calls surrogate halves. But what exactly are surrogate halves? I've never heard of the term before. I tried googling on "what is a golang surrogate half", but all it does is tell me, once again, that a surrogate half is illegal in a rune literal or a string literal. It doesn't tell me what a surrogate half is, which is what I want to know.
Ah, so a surrogate half is a sixteen-bit entity in the UTF-16 range reserved for either half of a Unicode character that can't be represented in 16 bits. If something is processing a 16-bit item and discovers it's in the range 0xD800 to 0xDFFF, then it knows to pair it with either the 16-bit value before it or the 16-bit value after it, in order to generate the desired Unicode character. Thanks for pointing me to this website!
Yeah. What he said. Totally. Wait. What? Sorry, I was looking at this tiny ad: