Win a copy of GANs in ActionE this week in the AI forum
or WebAssembly in Action in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

What Is a Surrogate Half?

 
Ranch Hand
Posts: 224
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 14734
244
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
search for Unicode surrogate pairs
 
Kevin Simonson
Ranch Hand
Posts: 224
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Junilu Lacar wrote:search for Unicode surrogate pairs


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:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!