diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9cf8fa4..70b34ad 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,7 +11,7 @@ jobs: matrix: version: - '1.6' - - '1.7' + - '1.9' - 'nightly' os: - ubuntu-latest diff --git a/Project.toml b/Project.toml index d581837..1f9de83 100644 --- a/Project.toml +++ b/Project.toml @@ -4,7 +4,7 @@ authors = ["ScottPJones "] keywords = ["Strings"] license = "MIT" uuid = "e79e7a6a-7bb1-5a4d-9d64-da657b06f53a" -version = "1.1.4" +version = "1.1.5" [deps] Unicode = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" diff --git a/src/encode.jl b/src/encode.jl index 9e77947..307af07 100644 --- a/src/encode.jl +++ b/src/encode.jl @@ -195,6 +195,8 @@ function convert(::Type{T}, Str(C, _str_cpy(UInt8, vec, length(vec))) end +convert(::Type{UniStr}, vec::AbstractArray{UInt8}) = _str(vec) + convert(::Type{<:Str{C}}, vec::AbstractArray{UInt8}) where {C<:Union{BinaryCSE,Text1CSE}} = Str(C, _str_cpy(UInt8, vec, length(vec))) convert(::Type{<:Str{Text2CSE}}, vec::AbstractArray{UInt16}) = @@ -210,6 +212,7 @@ convert(::Type{<:Str{Text4CSE}}, vec::AbstractArray{UInt32}) = (::Type{UniStr})(str::String) = _str(str) (::Type{UniStr})(str::Str{<:Union{ASCIICSE,SubSet_CSEs}}) = str +# need to fix this, should only allow already validated strings function convert(::Type{UniStr}, str::T) where {T<:Str} # handle zero length string quickly is_empty(str) && return empty_ascii diff --git a/src/util.jl b/src/util.jl index 7be3208..0a7111e 100644 --- a/src/util.jl +++ b/src/util.jl @@ -1,7 +1,7 @@ #= Utility functions for Str strings -Copyright 2018-2021 Gandalf Software, Inc., Scott P. Jones, +Copyright 2018-2023 Gandalf Software, Inc., Scott P. Jones, and other contributors to the Julia language Licensed under MIT License, see LICENSE.md Based initially on julia/test/strings/util.jl @@ -131,16 +131,21 @@ split(str::_SplitTypes, splitter::SetOfChars; limit::Integer=0, keepempty::Bool=true, keep::Union{Nothing,Bool}=nothing) = __split(str, in(splitter), limit, checkkeep(keepempty, keep, :split), splitarr(str)) +@static if isdefined(Base, :eachrsplit) +const _RSplitTypes = MaybeSub{<:Str{<:Union{_LatinCSE,_UCS2CSE,_UTF32CSE}}} +else +const _RSplitTypes = MaybeSub{<:Str} Base._rsplit(str::MaybeSub{<:Str}, splitter, limit, keepempty, vec) = __rsplit(str, splitter, limit, keepempty, vec) +end -rsplit(str::MaybeSub{<:Str}, splitter; +rsplit(str::_RSplitTypes, splitter; limit::Integer=0, keepempty::Bool=true, keep::Union{Nothing,Bool}=nothing) = __rsplit(str, splitter, limit, checkkeep(keepempty, keep, :rsplit), splitarr(str)) -rsplit(str::MaybeSub{<:Str}, splitter::AbstractChar; +rsplit(str::_RSplitTypes, splitter::AbstractChar; limit::Integer=0, keepempty::Bool=true, keep::Union{Nothing,Bool}=nothing) = __rsplit(str, isequal(splitter), limit, checkkeep(keepempty, keep, :rsplit), splitarr(str)) -rsplit(str::MaybeSub{<:Str}, splitter::SetOfChars; +rsplit(str::_RSplitTypes, splitter::SetOfChars; limit::Integer=0, keepempty::Bool=true, keep::Union{Nothing,Bool}=nothing) = __rsplit(str, in(splitter), limit, checkkeep(keepempty, keep, :rsplit), splitarr(str))