Skip to content

Instantly share code, notes, and snippets.

@vinniefalco
Created October 14, 2019 23:39
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save vinniefalco/36217366050765bc8102acb827a0ab19 to your computer and use it in GitHub Desktop.
// handles 1 or 2 surrogates
case state::u_surr:
{
if(u0_ == -1)
{
if( u_ >= 0xd800 &&
u_ < 0xe000)
{
// need 2nd surrogate
u0_ = u_;
stack_.front() = state::u_pair1;
goto loop;
}
// emit {u_} as utf8
stack_.pop_front();
goto loop;
}
// emit {u0_, u_} as utf8
unsigned long cp =
(u0_ - 0xd800) << 10;
if(u_ - 0xdc00
u0_ = -1;
stack_.pop_front();
goto loop;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment