From e406028e258c8692b066c3fd3646b4d4d41de7c7 Mon Sep 17 00:00:00 2001 From: Fijxu Date: Sun, 2 Aug 2026 22:44:01 -0400 Subject: [PATCH] Revert "Fix disappearing end of the comments with emoji (#5587)" This reverts commit 86c425b43f75dd1f22034bbfbd99476651661348. --- src/invidious/videos/description.cr | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/invidious/videos/description.cr b/src/invidious/videos/description.cr index 18b4122eb..1371bebb0 100644 --- a/src/invidious/videos/description.cr +++ b/src/invidious/videos/description.cr @@ -21,6 +21,8 @@ private def copy_string(str : String::Builder, iter : Iterator, count : Int) : I str << cp.chr end + # A codepoint from the SMP counts twice + copied += 1 if cp > 0xFFFF copied += 1 end @@ -42,6 +44,10 @@ def parse_description(desc, video_id : String) : String? end end + # Not everything is stored in UTF-8 on youtube's side. The SMP codepoints + # (0x10000 and above) are encoded as UTF-16 surrogate pairs, which are + # automatically decoded by the JSON parser. It means that we need to count + # copied byte in a special manner, preventing the use of regular string copy. iter = content.each_codepoint index = 0