JuliaLang/julia

transcode(String, ::Vector{UInt}) is destructive

クローズ

#28,612 opened on 2018/08/12

 (2 件のコメント) (0 件のリアクション) (1 人の担当者)Julia (5,773 件のフォーク)batch import
arraysgood first issuestrings

Repository metrics

Stars
 (48,709 個のスター)
PR merge metrics
 (平均マージ 20d 6h) (30d で 157 merged PRs)

説明

I'm seeing the following behaviour on 1.0:

julia> a = collect(transcode(UInt8, "abc"))
3-element Array{UInt8,1}:
 0x61
 0x62
 0x63

julia> b = transcode(String, a)
"abc"

julia> a
0-element Array{UInt8,1}

Note that this is only the case when a is a Vector{UInt8} (obtained through collect). When keeping the CodeUnits variable returned by the transcode(UInt8,...) call, there is no destruction:

julia> a = transcode(UInt8, "abc")
3-element Base.CodeUnits{UInt8,String}:
 0x61
 0x62
 0x63

julia> b = transcode(String, a)
"abc"

julia> a
3-element Base.CodeUnits{UInt8,String}:
 0x61
 0x62
 0x63

コントリビューターガイド