Created
October 14, 2019 23:52
-
-
Save vinniefalco/c693a08bf010bcec5eb5f91aaf6e62da to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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