All of these arguments about byte indexing apply equally to first, last, and chop, which are part of the standard library and index on unicode codepoints.
From the julia source:
first(s::AbstractString, n::Integer) = @inbounds s[1:min(end, nextind(s, 0, n))]
last(s::AbstractString, n::Integer) = @inbounds s[max(1, prevind(s, ncodeunits(s)+1, n)):end]
function chop(s::AbstractString; head::Integer = 0, tail::Integer = 1)
if isempty(s)
return SubString(s)
end
SubString(s, nextind(s, firstindex(s), head), prevind(s, lastindex(s), tail))
end
Guess I’ll just have to start my own util package like you do in Java ![]()