Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
tkluck opened this issue Aug 12, 2018 · 2 comments
Open

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

tkluck opened this issue Aug 12, 2018 · 2 comments
Assignees

Comments

@tkluck
Copy link
Contributor

tkluck commented Aug 12, 2018

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
@sambitdash
Copy link
Contributor

@KristofferC
Copy link
Member

See #32255 for a PR fixing a similar issue.

@StefanKarpinski StefanKarpinski self-assigned this Aug 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants