Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// handles 1 or 2 surrogates
case state::u_surr:
{
// one code unit
if(u0_ == -1)
{
if( u_ >= 0xd800)
{
if(u_ <= 0xdbff)
{
// need 2nd surrogate
u0_ = u_;
stack_.front() = state::u_pair1;
goto loop;
}
else if(u_ <= 0xdfff)
{
ec = error::illegal_leading_surrogate;
goto finish;
}
}
// emit {u_} as utf8
stack_.pop_front();
goto loop;
}
// both code units
if( u_ < 0xdc00 ||
u_ >= 0xdfff)
{
ec = error::illegal_trailing_surrogate;
goto finish;
}
// 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
You can’t perform that action at this time.