mirror of
https://github.com/iv-org/invidious.git
synced 2026-02-17 17:48:32 -06:00
description.cr updated
Co-authored-by: Fijxu <fijxu@nadeko.net>
This commit is contained in:
parent
0e5809c536
commit
51aab0681b
@ -29,10 +29,16 @@ private def copy_string(str : String::Builder, iter : Iterator, count : Int) : I
|
|||||||
return copied
|
return copied
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# size < bytesize, so we need to count the number of characters that are
|
||||||
|
# two UInt16 wide.
|
||||||
|
# Taken from: https://github.com/crystal-lang/crystal/blob/8fa7f90c091aa3757821c04ee243c7ab5f67ac20/src/string/utf16.cr#L18-L20
|
||||||
private def utf16_length(content : String) : Int32
|
private def utf16_length(content : String) : Int32
|
||||||
content.each_char.sum { |ch| ch.ord >= 0x10000 ? 2 : 1 }
|
u16_size = 0
|
||||||
|
content.each_char do |char|
|
||||||
|
u16_size += char.ord < 0x1_0000 ? 1 : 2
|
||||||
|
end
|
||||||
|
u16_size
|
||||||
end
|
end
|
||||||
|
|
||||||
def parse_description(desc, video_id : String) : String?
|
def parse_description(desc, video_id : String) : String?
|
||||||
return "" if desc.nil?
|
return "" if desc.nil?
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user