Skip to content

Commit 8120e2c

Browse files
committed
support convert for UniStr from Vector{UInt8}
1 parent 5d1b7c3 commit 8120e2c

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

src/encode.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,8 @@ function convert(::Type{T},
195195
Str(C, _str_cpy(UInt8, vec, length(vec)))
196196
end
197197

198+
convert(::Type{UniStr}, vec::AbstractArray{UInt8}) = _str(vec)
199+
198200
convert(::Type{<:Str{C}}, vec::AbstractArray{UInt8}) where {C<:Union{BinaryCSE,Text1CSE}} =
199201
Str(C, _str_cpy(UInt8, vec, length(vec)))
200202
convert(::Type{<:Str{Text2CSE}}, vec::AbstractArray{UInt16}) =
@@ -210,6 +212,7 @@ convert(::Type{<:Str{Text4CSE}}, vec::AbstractArray{UInt32}) =
210212
(::Type{UniStr})(str::String) = _str(str)
211213
(::Type{UniStr})(str::Str{<:Union{ASCIICSE,SubSet_CSEs}}) = str
212214

215+
# need to fix this, should only allow already validated strings
213216
function convert(::Type{UniStr}, str::T) where {T<:Str}
214217
# handle zero length string quickly
215218
is_empty(str) && return empty_ascii

0 commit comments

Comments
 (0)