Skip to content

Commit

Permalink
utf8: Fix encoding of U+FFFE and U+FFFF
Browse files Browse the repository at this point in the history
  • Loading branch information
nwellnhof committed Apr 23, 2024
1 parent 2632fdc commit 12f5205
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
6 changes: 0 additions & 6 deletions src/utf8.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,6 @@ void cmark_utf8proc_encode_char(int32_t uc, cmark_strbuf *buf) {
dst[0] = (uint8_t)(0xC0 + (uc >> 6));
dst[1] = 0x80 + (uc & 0x3F);
len = 2;
} else if (uc == 0xFFFF) {
dst[0] = 0xFF;
len = 1;
} else if (uc == 0xFFFE) {
dst[0] = 0xFE;
len = 1;
} else if (uc < 0x10000) {
dst[0] = (uint8_t)(0xE0 + (uc >> 12));
dst[1] = 0x80 + ((uc >> 6) & 0x3F);
Expand Down
7 changes: 7 additions & 0 deletions test/regression.txt
Original file line number Diff line number Diff line change
Expand Up @@ -275,3 +275,10 @@ Case fold test
.
<p><a href="/url">link</a></p>
````````````````````````````````

https://github.com/commonmark/cmark/issues/548
```````````````````````````````` example
(&#xFFFE;&#xFFFF;)
.
<p>(￾￿)</p>
````````````````````````````````
Expand Down

0 comments on commit 12f5205

Please sign in to comment.