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

Taking a String from an Array{UInt8} empties the array #34407

Closed
neonlogic opened this issue Jan 16, 2020 · 1 comment
Closed

Taking a String from an Array{UInt8} empties the array #34407

neonlogic opened this issue Jan 16, 2020 · 1 comment

Comments

@neonlogic
Copy link

Using the String constructor with an Array{UInt8} as an argument seems to construct the string by interpreting the array's content as ASCII or UTF-8. It is not clear to me whether this is by design - other languages such as Python would never allow this without an explicit specification of the desired encoding.
What is surprising, however, is that the array's contents disappear in the process. This is certainly not intuitive and probably not intended.

julia> a = [0x30, 0x31]
2-element Array{UInt8,1}:
 0x30
 0x31

julia> String(a)
"01"

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

Using Julia version 1.3.1 (2019-12-30)

@yuyichao
Copy link
Contributor

This is intended, (I believe) documentd but unintuitive.

Dup of #32528

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

2 participants