Conversion of Vector{UInt8} to String without copy

I’ve often felt there should be package (VectorStrings.jl?) for this: a safe (unlike WeakRefStrings), full-featured string type that wraps an arbitrary AbstractVector{UInt8}. This also came up recently in discussions of mmapping strings.

It wouldn’t be too hard to write; I’d be willing to help out if someone wanted to start such a package (under https://github.com/JuliaStrings).

There would be a fair amount of copy-and-paste code from Base.String, but that’s not so terrible — the String code has been stable for a long while. (Alternatively, one could add an AbstractByteString type to Base and generalize a bunch of String methods, but that’s not going to happen any time soon; it would be better to try it out in a package first and then potentially merge into Base later if it proves very useful.

1 Like