Skip to content

Commit

Permalink
Fix UTF-8 code points emitting (jbeder#571)
Browse files Browse the repository at this point in the history
  • Loading branch information
maek authored and jbeder committed Mar 24, 2018
1 parent 562aefc commit f996468
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/emitterutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,12 @@ void WriteCodePoint(ostream_wrapper& out, int codePoint) {
if (codePoint < 0 || codePoint > 0x10FFFF) {
codePoint = REPLACEMENT_CHARACTER;
}
if (codePoint < 0x7F) {
if (codePoint <= 0x7F) {
out << static_cast<char>(codePoint);
} else if (codePoint < 0x7FF) {
} else if (codePoint <= 0x7FF) {
out << static_cast<char>(0xC0 | (codePoint >> 6))
<< static_cast<char>(0x80 | (codePoint & 0x3F));
} else if (codePoint < 0xFFFF) {
} else if (codePoint <= 0xFFFF) {
out << static_cast<char>(0xE0 | (codePoint >> 12))
<< static_cast<char>(0x80 | ((codePoint >> 6) & 0x3F))
<< static_cast<char>(0x80 | (codePoint & 0x3F));
Expand Down

0 comments on commit f996468

Please sign in to comment.