`transcode(String, arr)` sets the `arr` length to 0 elements

Hi All,

Is this behavior of transcode expected? Should transcode not be a function without side effects?

regards,

Sambit

julia> PADDING1 =
           [0x28, 0xBF, 0x4E, 0x5E]
4-element Array{UInt8,1}:
 0x28
 0xbf
 0x4e
 0x5e

julia> str = transcode(String, PADDING1)
"(\xbfN^"

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

julia> versioninfo()
Julia Version 1.1.0
Commit 80516ca202 (2019-01-21 21:24 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i7-6500U CPU @ 2.50GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.1 (ORCJIT, skylake)

This is an unfortunate consequence of calling String on a Vector{UInt8} in the implementation of transcode.

I agree that this is confusing. If there is no existing issue, please open one.

Already reported:

https://github.com/JuliaLang/julia/issues/28612

regards,

Sambit

1 Like