mirror of
https://gitea.invidious.io/iv-org/protodec.git
synced 2024-08-15 00:43:18 +00:00
Fix size for string encoding
This commit is contained in:
parent
b08f41bd3c
commit
ce002cbd3e
1 changed files with 4 additions and 4 deletions
|
@ -214,22 +214,22 @@ struct ProtoBuf::Any
|
||||||
when "float64"
|
when "float64"
|
||||||
value.as_f32.to_f64.to_io(io, IO::ByteFormat::LittleEndian)
|
value.as_f32.to_f64.to_io(io, IO::ByteFormat::LittleEndian)
|
||||||
when "string"
|
when "string"
|
||||||
VarLong.to_io(io, value.as_s.size.to_i64)
|
VarLong.to_io(io, value.as_s.bytesize.to_i64)
|
||||||
value.as_s.to_s(io)
|
io.print value.as_s
|
||||||
when "base64"
|
when "base64"
|
||||||
buffer = IO::Memory.new
|
buffer = IO::Memory.new
|
||||||
from_json(value, buffer)
|
from_json(value, buffer)
|
||||||
buffer.rewind
|
buffer.rewind
|
||||||
|
|
||||||
buffer = Base64.urlsafe_encode(buffer, padding: false)
|
buffer = Base64.urlsafe_encode(buffer, padding: false)
|
||||||
VarLong.to_io(io, buffer.size.to_i64)
|
VarLong.to_io(io, buffer.bytesize.to_i64)
|
||||||
buffer.to_s(io)
|
buffer.to_s(io)
|
||||||
when "embedded"
|
when "embedded"
|
||||||
buffer = IO::Memory.new
|
buffer = IO::Memory.new
|
||||||
from_json(value, buffer)
|
from_json(value, buffer)
|
||||||
buffer.rewind
|
buffer.rewind
|
||||||
|
|
||||||
VarLong.to_io(io, buffer.size.to_i64)
|
VarLong.to_io(io, buffer.bytesize.to_i64)
|
||||||
IO.copy(buffer, io)
|
IO.copy(buffer, io)
|
||||||
when "bytes"
|
when "bytes"
|
||||||
VarLong.to_io(io, value.size.to_i64)
|
VarLong.to_io(io, value.size.to_i64)
|
||||||
|
|
Loading…
Reference in a new issue