Skip to content

Commit 86c425b

Browse files
shiny-comicshiny-comic
andauthored
Fix disappearing end of the comments with emoji (#5587)
Previous code use UTF-8 to count characters however Emojis are UTF-16 units. This difference leads to misalignment of index offsets. Co-authored-by: shiny-comic <shiny-comic@winPC>
1 parent 4ae227c commit 86c425b

1 file changed

Lines changed: 0 additions & 6 deletions

File tree

src/invidious/videos/description.cr

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ private def copy_string(str : String::Builder, iter : Iterator, count : Int) : I
2121
str << cp.chr
2222
end
2323

24-
# A codepoint from the SMP counts twice
25-
copied += 1 if cp > 0xFFFF
2624
copied += 1
2725
end
2826

@@ -44,10 +42,6 @@ def parse_description(desc, video_id : String) : String?
4442
end
4543
end
4644

47-
# Not everything is stored in UTF-8 on youtube's side. The SMP codepoints
48-
# (0x10000 and above) are encoded as UTF-16 surrogate pairs, which are
49-
# automatically decoded by the JSON parser. It means that we need to count
50-
# copied byte in a special manner, preventing the use of regular string copy.
5145
iter = content.each_codepoint
5246

5347
index = 0

0 commit comments

Comments
 (0)