Base.CodeUnits
seems to wrap it automatically. Is this intended, or a bug? How can I get a Vector{UInt8}
using string literals the same way both in v0.6
and v0.7-
?
julia> Meta.lower(Main, :(b"123"))
:($(QuoteNode(UInt8[0x31, 0x32, 0x33])))
julia> b"123"
3-element Base.CodeUnits{UInt8,String}:
0x31
0x32
0x33
julia> VERSION
v"0.7.0-DEV.3385"
I see that it is actually a DenseVector
. Perhaps it is just the manual being out of sync.
See https://github.com/JuliaLang/julia/pull/25373, where this was changed.
Why do you need a Vector{UInt8}
specifically? Because you need a mutable array? (Apparently, it was mutable previously but returned the same vector every time, which caused its own problems.)
Nope, I was just dispatching on Vector{UInt8}
. Using Compat.jl
, I can replace it with DenseVector
and have it work in both versions. Thanks!
Note that if you really need DenseVector
, you may need to also check stride(A,1) == 1
if you need contiguous memory.