JuliaLang/julia — pull request #5703 by stevengj (2014-02-06 17:09:03+00:00)
Title: RFC: add pointer(s::Union(ByteString,UTF16String,UTF32String))

This patch adds `pointer(s)` for `s::Union(ByteString,UTF16String,UTF32String)` and substrings thereof. Not only is this more convenient than `convert(Ptr{Foo}, s)` (because `s` knows the correct pointer type), but it also works for arbitrary substrings (whereas `convert` throws an error if the substring is not at the end).

The patch also changes the `chars` field of `UTF32String` to `data` for consistency with our other string types; this makes it easier to write methods that work on `Union(ByteString,UTF16String,UTF32String)`.

Also, I changed the signature in `pointer{T}(x::AbstractArray{T}, i::Int)` to `pointer{T}(x::AbstractArray{T}, i::Integer)`, since I couldn't see any reason to restrict the index to `Int` here.