From f89e5ed2de079f9e786dfb27da6fda86ff890199 Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Tue, 9 Jan 2018 17:36:44 -0500 Subject: [PATCH] move case functions and char predicates back to Base fixes #25394 --- CONTRIBUTING.md | 2 +- NEWS.md | 14 ++-- base/arrayshow.jl | 2 +- base/char.jl | 2 +- base/deprecated.jl | 21 ++---- base/dict.jl | 4 +- base/docs/utils.jl | 5 +- base/exports.jl | 16 +++++ base/interactiveutil.jl | 2 +- base/io.jl | 2 - base/libuv.jl | 4 +- base/markdown/Markdown.jl | 1 - base/mpfr.jl | 2 +- base/operators.jl | 2 - base/parse.jl | 18 ++--- base/pkg/entry.jl | 2 +- base/pkg/reqs.jl | 2 +- base/precompile.jl | 3 - base/printf.jl | 1 - base/process.jl | 2 +- base/random/misc.jl | 2 +- base/regex.jl | 6 +- base/repl/LineEdit.jl | 2 - base/repl/REPL.jl | 2 +- base/shell.jl | 8 +-- base/show.jl | 2 +- base/stream.jl | 2 +- base/strings/io.jl | 8 +-- base/strings/strings.jl | 4 ++ base/strings/unicode.jl | 75 --------------------- base/util.jl | 2 +- doc/src/base/strings.md | 17 +++++ doc/src/manual/unicode-input.md | 4 +- stdlib/Dates/src/parse.jl | 4 +- stdlib/Dates/src/periods.jl | 2 +- stdlib/Dates/src/query.jl | 4 +- stdlib/Dates/test/io.jl | 2 +- stdlib/Distributed/src/Distributed.jl | 1 - stdlib/Distributed/test/distributed_exec.jl | 1 - stdlib/Unicode/docs/src/index.md | 18 ----- stdlib/Unicode/src/Unicode.jl | 11 +-- stdlib/Unicode/test/runtests.jl | 16 ++--- test/dict.jl | 4 +- test/docs.jl | 6 +- test/iobuffer.jl | 3 +- test/iostream.jl | 3 +- test/libgit2.jl | 1 - test/operators.jl | 6 +- test/perf/kernel/json.jl | 2 +- test/perf/perfgeneric.jl | 2 +- test/perf/shootout/k_nucleotide.jl | 2 +- test/perf/spell/perf.jl | 2 +- test/strings/basic.jl | 6 +- test/strings/io.jl | 4 +- test/strings/util.jl | 2 +- 55 files changed, 120 insertions(+), 223 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ba5c8f78a63594..b5f41ab43798d4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -174,7 +174,7 @@ The steps required to add a new docstring are listed below: Examples written within docstrings can be used as testcases known as "doctests" by annotating code blocks with `jldoctest`. ```jldoctest - julia> Unicode.uppercase("Docstring test") + julia> uppercase("Docstring test") "DOCSTRING TEST" ``` diff --git a/NEWS.md b/NEWS.md index d09f779206d899..525ab4e45aca8f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -863,21 +863,17 @@ Deprecated or removed * The `sum_kbn` and `cumsum_kbn` functions have been moved to the [KahanSummation](https://github.com/JuliaMath/KahanSummation.jl) package ([#24869]). - * Unicode-related string functions have been moved to the new `Unicode` standard - library module ([#25021]). This applies to `normalize_string`, `graphemes`, - `is_assigned_char`, `textwidth`, `islower`, `isupper`, `isalpha`, - `isdigit`, `isxdigit`, `isnumber`, `isalnum`, `iscntrl`, `ispunct`, `isspace`, - `isprint`, `isgraph`, `lowercase`, `uppercase`, `titlecase`, `lcfirst` and `ucfirst`. + * `isnumber` has been renamed to `isnumeric` ([#25021]). + + * `is_assigned_char` and `normalize_string` have been renamed to `isassigned` and + `normalize`, and moved to the new `Unicode` standard library module. + `graphemes` has also been moved to that module ([#25021]). * The functions `eigs` and `svds` have been moved to the `IterativeEigensolvers` standard library module ([#24714]). * `@printf` and `@sprintf` have been moved to the `Printf` standard library ([#23929],[#25056]). - * `isnumber` has been deprecated in favor of `isnumeric`, `is_assigned_char` - in favor of `isassigned` and `normalize_string` in favor of `normalize`, all three - in the new `Unicode` standard library module ([#25021]). - * The aliases `Complex32`, `Complex64` and `Complex128` have been deprecated in favor of `ComplexF16`, `ComplexF32` and `ComplexF64` respectively ([#24647]). diff --git a/base/arrayshow.jl b/base/arrayshow.jl index 9fc7f6e9e144be..e731588de8e85e 100644 --- a/base/arrayshow.jl +++ b/base/arrayshow.jl @@ -166,7 +166,7 @@ function print_matrix(io::IO, X::AbstractVecOrMat, screenwidth -= length(pre) + length(post) presp = repeat(" ", length(pre)) # indent each row to match pre string postsp = "" - @assert Unicode.textwidth(hdots) == Unicode.textwidth(ddots) + @assert textwidth(hdots) == textwidth(ddots) sepsize = length(sep) rowsA, colsA = axes(X,1), axes(X,2) m, n = length(rowsA), length(colsA) diff --git a/base/char.jl b/base/char.jl index 717881c37d05c4..1581123307643a 100644 --- a/base/char.jl +++ b/base/char.jl @@ -127,7 +127,7 @@ function show(io::IO, c::Char) (u <<= 8) == 0 && break end write(io, 0x27) - elseif Unicode.isprint(c) + elseif isprint(c) write(io, 0x27, c, 0x27) else # unprintable, well-formed, non-overlong Unicode u = UInt32(c) diff --git a/base/deprecated.jl b/base/deprecated.jl index bc1551c6e24edc..1080830be5bb74 100644 --- a/base/deprecated.jl +++ b/base/deprecated.jl @@ -2801,23 +2801,10 @@ end @deprecate_moved normalize_string "Unicode" true true @deprecate_moved graphemes "Unicode" true true @deprecate_moved is_assigned_char "Unicode" true true -@deprecate_moved textwidth "Unicode" true true -@deprecate_moved islower "Unicode" true true -@deprecate_moved isupper "Unicode" true true -@deprecate_moved isalpha "Unicode" true true -@deprecate_moved isdigit "Unicode" true true -@deprecate_moved isnumber "Unicode" true true -@deprecate_moved isalnum "Unicode" true true -@deprecate_moved iscntrl "Unicode" true true -@deprecate_moved ispunct "Unicode" true true -@deprecate_moved isspace "Unicode" true true -@deprecate_moved isprint "Unicode" true true -@deprecate_moved isgraph "Unicode" true true -@deprecate_moved lowercase "Unicode" true true -@deprecate_moved uppercase "Unicode" true true -@deprecate_moved titlecase "Unicode" true true -@deprecate_moved lcfirst "Unicode" true true -@deprecate_moved ucfirst "Unicode" true true + +@deprecate isalnum(c::Char) isalpha(c) || isnumeric(c) +@deprecate isgraph(c::Char) isprint(c) && !isspace(c) +@deprecate isnumber(c::Char) isnumeric(c) # PR #24647 @deprecate_binding Complex32 ComplexF16 diff --git a/base/dict.jl b/base/dict.jl index 3e5534885318a3..2f0df65d01a4dd 100644 --- a/base/dict.jl +++ b/base/dict.jl @@ -1,7 +1,7 @@ # This file is a part of Julia. License is MIT: https://julialang.org/license function _truncate_at_width_or_chars(str, width, chars="", truncmark="…") - truncwidth = Unicode.textwidth(truncmark) + truncwidth = textwidth(truncmark) (width <= 0 || width < truncwidth) && return "" wid = truncidx = lastidx = 0 @@ -9,7 +9,7 @@ function _truncate_at_width_or_chars(str, width, chars="", truncmark="…") while !done(str, idx) lastidx = idx c, idx = next(str, idx) - wid += Unicode.textwidth(c) + wid += textwidth(c) wid >= width - truncwidth && truncidx == 0 && (truncidx = lastidx) (wid >= width || c in chars) && break end diff --git a/base/docs/utils.jl b/base/docs/utils.jl index 88d9db3c124d5e..85db2c97ed81d4 100644 --- a/base/docs/utils.jl +++ b/base/docs/utils.jl @@ -3,7 +3,6 @@ # Text / HTML objects import Base: print, show, ==, hash -using Base.Unicode export HTML, @html_str @@ -222,8 +221,8 @@ function matchinds(needle, haystack; acronym = false) for (i, char) in enumerate(haystack) isempty(chars) && break while chars[1] == ' ' popfirst!(chars) end # skip spaces - if Unicode.lowercase(char) == Unicode.lowercase(chars[1]) && - (!acronym || !Unicode.isalpha(lastc)) + if lowercase(char) == lowercase(chars[1]) && + (!acronym || !isalpha(lastc)) push!(is, i) popfirst!(chars) end diff --git a/base/exports.jl b/base/exports.jl index bbc505393a62e8..be605b61091c74 100644 --- a/base/exports.jl +++ b/base/exports.jl @@ -703,7 +703,19 @@ export hex2bytes, hex2bytes!, info, + isalpha, isascii, + iscntrl, + isdigit, + islower, + isnumeric, + isprint, + ispunct, + isspace, + isupper, + isxdigit, + lcfirst, + lowercase, isvalid, join, logging, @@ -735,9 +747,13 @@ export string, strip, summary, + textwidth, thisind, + titlecase, transcode, + ucfirst, unescape_string, + uppercase, warn, # logging frontend diff --git a/base/interactiveutil.jl b/base/interactiveutil.jl index 7627362cdca0f8..1d5dc5b1c5938e 100644 --- a/base/interactiveutil.jl +++ b/base/interactiveutil.jl @@ -51,7 +51,7 @@ function edit(path::AbstractString, line::Integer=0) cmd = line != 0 ? `$command $path -l $line` : `$command $path` elseif startswith(name, "subl") || startswith(name, "atom") cmd = line != 0 ? `$command $path:$line` : `$command $path` - elseif name == "code" || (Sys.iswindows() && Unicode.uppercase(name) == "CODE.EXE") + elseif name == "code" || (Sys.iswindows() && uppercase(name) == "CODE.EXE") cmd = line != 0 ? `$command -g $path:$line` : `$command -g $path` elseif startswith(name, "notepad++") cmd = line != 0 ? `$command $path -n$line` : `$command $path` diff --git a/base/io.jl b/base/io.jl index f6882570b7031b..0df61faa2d5787 100644 --- a/base/io.jl +++ b/base/io.jl @@ -924,8 +924,6 @@ characters from that character until the start of the next line are ignored. julia> buf = IOBuffer(" text") IOBuffer(data=UInt8[...], readable=true, writable=false, seekable=true, append=false, size=8, maxsize=Inf, ptr=1, mark=-1) -julia> using Unicode - julia> skipchars(buf, isspace) IOBuffer(data=UInt8[...], readable=true, writable=false, seekable=true, append=false, size=8, maxsize=Inf, ptr=5, mark=-1) diff --git a/base/libuv.jl b/base/libuv.jl index 5ec3f16649b65f..2809554550fce3 100644 --- a/base/libuv.jl +++ b/base/libuv.jl @@ -20,10 +20,10 @@ function uv_sizeof_req(req) end for h in uv_handle_types -@eval const $(Symbol("_sizeof_",Unicode.lowercase(string(h)))) = uv_sizeof_handle($h) +@eval const $(Symbol("_sizeof_",lowercase(string(h)))) = uv_sizeof_handle($h) end for r in uv_req_types -@eval const $(Symbol("_sizeof_",Unicode.lowercase(string(r)))) = uv_sizeof_req($r) +@eval const $(Symbol("_sizeof_",lowercase(string(r)))) = uv_sizeof_req($r) end uv_handle_data(handle) = ccall(:jl_uv_handle_data,Ptr{Cvoid},(Ptr{Cvoid},),handle) diff --git a/base/markdown/Markdown.jl b/base/markdown/Markdown.jl index 82c14669739a3c..7fa7729b00cb59 100644 --- a/base/markdown/Markdown.jl +++ b/base/markdown/Markdown.jl @@ -7,7 +7,6 @@ module Markdown import Base: show, ==, with_output_color import Core: @doc_str -using Base.Unicode: lowercase, ucfirst, isspace include(joinpath("parse", "config.jl")) include(joinpath("parse", "util.jl")) diff --git a/base/mpfr.jl b/base/mpfr.jl index 2338581d149028..f6f9d53368920b 100644 --- a/base/mpfr.jl +++ b/base/mpfr.jl @@ -132,7 +132,7 @@ BigFloat(x::Union{Float16,Float32}) = BigFloat(Float64(x)) BigFloat(x::Rational) = BigFloat(numerator(x)) / BigFloat(denominator(x)) function tryparse(::Type{BigFloat}, s::AbstractString, base::Int=0) - !isempty(s) && Base.Unicode.isspace(s[end]) && return tryparse(BigFloat, rstrip(s), base) + !isempty(s) && isspace(s[end]) && return tryparse(BigFloat, rstrip(s), base) z = BigFloat() err = ccall((:mpfr_set_str, :libmpfr), Int32, (Ref{BigFloat}, Cstring, Int32, Int32), z, s, base, ROUNDING_MODE[]) err == 0 ? z : nothing diff --git a/base/operators.jl b/base/operators.jl index fb7c77fc361583..d238b289195f9f 100644 --- a/base/operators.jl +++ b/base/operators.jl @@ -763,8 +763,6 @@ entered in the Julia REPL (and most editors, appropriately configured) by typing # Examples ```jldoctest -julia> using Unicode - julia> map(uppercase∘hex, 250:255) 6-element Array{String,1}: "FA" diff --git a/base/parse.jl b/base/parse.jl index e0da3ea3030581..4b28b1c5359d02 100644 --- a/base/parse.jl +++ b/base/parse.jl @@ -53,7 +53,7 @@ end function parseint_preamble(signed::Bool, base::Int, s::AbstractString, startpos::Int, endpos::Int) c, i, j = parseint_next(s, startpos, endpos) - while Unicode.isspace(c) + while isspace(c) c, i, j = parseint_next(s,i,endpos) end (j == 0) && (return 0, 0, 0) @@ -66,7 +66,7 @@ function parseint_preamble(signed::Bool, base::Int, s::AbstractString, startpos: end end - while Unicode.isspace(c) + while isspace(c) c, i, j = parseint_next(s,i,endpos) end (j == 0) && (return 0, 0, 0) @@ -124,10 +124,10 @@ function tryparse_internal(::Type{T}, s::AbstractString, startpos::Int, endpos:: return n end c, i = next(s,i) - Unicode.isspace(c) && break + isspace(c) && break end (T <: Signed) && (n *= sgn) - while !Unicode.isspace(c) + while !isspace(c) d::T = '0' <= c <= '9' ? c-'0' : 'A' <= c <= 'Z' ? c-'A'+10 : 'a' <= c <= 'z' ? c-'a'+a : base @@ -148,7 +148,7 @@ function tryparse_internal(::Type{T}, s::AbstractString, startpos::Int, endpos:: end while i <= endpos c, i = next(s,i) - if !Unicode.isspace(c) + if !isspace(c) raise && throw(ArgumentError("extra characters after whitespace in $(repr(SubString(s,startpos,endpos)))")) return nothing end @@ -167,10 +167,10 @@ function tryparse_internal(::Type{Bool}, sbuff::Union{String,SubString{String}}, orig_end = endpos # Ignore leading and trailing whitespace - while Unicode.isspace(sbuff[startpos]) && startpos <= endpos + while isspace(sbuff[startpos]) && startpos <= endpos startpos = nextind(sbuff, startpos) end - while Unicode.isspace(sbuff[endpos]) && endpos >= startpos + while isspace(sbuff[endpos]) && endpos >= startpos endpos = prevind(sbuff, endpos) end @@ -185,7 +185,7 @@ function tryparse_internal(::Type{Bool}, sbuff::Union{String,SubString{String}}, if raise substr = SubString(sbuff, orig_start, orig_end) # show input string in the error to avoid confusion - if all(Unicode.isspace, substr) + if all(isspace, substr) throw(ArgumentError("input string only contains whitespace")) else throw(ArgumentError("invalid Bool representation: $(repr(substr))")) @@ -272,7 +272,7 @@ tryparse_internal(::Type{Float16}, s::AbstractString, startpos::Int, endpos::Int function tryparse_internal(::Type{Complex{T}}, s::Union{String,SubString{String}}, i::Int, e::Int, raise::Bool) where {T<:Real} # skip initial whitespace - while i ≤ e && Unicode.isspace(s[i]) + while i ≤ e && isspace(s[i]) i = nextind(s, i) end if i > e diff --git a/base/pkg/entry.jl b/base/pkg/entry.jl index fb6c808eb161cd..758a8b2f7bc2be 100644 --- a/base/pkg/entry.jl +++ b/base/pkg/entry.jl @@ -92,7 +92,7 @@ function available() for (pkg, vers) in all_avail any(x->Types.satisfies("julia", VERSION, x[2].requires), vers) && push!(avail, pkg) end - sort!(avail, by=Base.Unicode.lowercase) + sort!(avail, by=lowercase) end function available(pkg::AbstractString) diff --git a/base/pkg/reqs.jl b/base/pkg/reqs.jl index 7bc9db969bbef9..3c15fd918e80bf 100644 --- a/base/pkg/reqs.jl +++ b/base/pkg/reqs.jl @@ -78,7 +78,7 @@ function write(io::IO, lines::Vector{Line}) end end function write(io::IO, reqs::Requires) - for pkg in sort!(collect(keys(reqs)), by=Unicode.lowercase) + for pkg in sort!(collect(keys(reqs)), by=lowercase) println(io, Requirement(pkg, reqs[pkg]).content) end end diff --git a/base/precompile.jl b/base/precompile.jl index b19f6e7f1625d3..ab3f451d7992a2 100644 --- a/base/precompile.jl +++ b/base/precompile.jl @@ -60,7 +60,6 @@ precompile(Tuple{typeof(Base.lstrip), Base.SubString{String}, Array{Char, 1}}) precompile(Tuple{getfield(Base, Symbol("#kw##split")), Array{Any, 1}, typeof(Base.split), String, Char}) precompile(Tuple{getfield(Base, Symbol("#kw##split")), Array{Any, 1}, typeof(Base.split), Base.SubString{String}, Char}) precompile(Tuple{typeof(Base.map!), typeof(Base.strip), Array{Base.SubString{String}, 1}, Array{Base.SubString{String}, 1}}) -precompile(Tuple{typeof(Base.Unicode.isnumeric), Base.SubString{String}}) precompile(Tuple{Type{Core.Inference.Generator{I, F} where F where I}, Type{Core.Inference.Const}, Tuple{Tuple{Base.DevNullStream, Base.DevNullStream, Base.DevNullStream}}}) precompile(Tuple{Type{Core.Inference.Generator{Tuple{Tuple{Base.DevNullStream, Base.DevNullStream, Base.DevNullStream}}, Type{Core.Inference.Const}}}, Type{Core.Inference.Const}, Tuple{Tuple{Base.DevNullStream, Base.DevNullStream, Base.DevNullStream}}}) precompile(Tuple{typeof(Core.Inference.convert), Type{Tuple{Tuple{Base.DevNullStream, Base.DevNullStream, Base.DevNullStream}}}, Tuple{Tuple{Base.DevNullStream, Base.DevNullStream, Base.DevNullStream}}}) @@ -747,7 +746,6 @@ precompile(Tuple{Type{Base.Generator{I, F} where F where I}, typeof(Base.string) precompile(Tuple{typeof(Base._collect), Array{Any, 1}, Base.Generator{Array{Any, 1}, typeof(Base.string)}, Base.EltypeUnknown, Base.HasShape}) precompile(Tuple{typeof(Base.similar), Array{Any, 1}, Type{String}, Tuple{Base.OneTo{Int64}}}) precompile(Tuple{typeof(Base.collect_to!), Array{String, 1}, Base.Generator{Array{Any, 1}, typeof(Base.string)}, Int64, Int64}) -precompile(Tuple{typeof(Base.Unicode.isalpha), Char}) precompile(Tuple{getfield(Base.Docs, Symbol("#kw##matchinds")), Array{Any, 1}, typeof(Base.Docs.matchinds), String, String}) precompile(Tuple{typeof(Base.Docs.bestmatch), String, String}) precompile(Tuple{typeof(Base.length), Tuple{DataType, DataType}}) @@ -910,7 +908,6 @@ precompile(Tuple{typeof(Base.lstrip), String, Char}) precompile(Tuple{typeof(Base.Markdown.blockquote), Base.GenericIOBuffer{Array{UInt8, 1}}, Base.Markdown.MD}) precompile(Tuple{getfield(Base.Markdown, Symbol("#kw##parse")), Array{Any, 1}, typeof(Base.Markdown.parse), String}) precompile(Tuple{typeof(Base.Markdown.admonition), Base.GenericIOBuffer{Array{UInt8, 1}}, Base.Markdown.MD}) -precompile(Tuple{typeof(Base.Unicode.isupper), Char}) precompile(Tuple{getfield(Base.Markdown, Symbol("#kw##linecontains")), Array{Any, 1}, typeof(Base.Markdown.linecontains), Base.GenericIOBuffer{Array{UInt8, 1}}, String}) precompile(Tuple{typeof(Base.ucfirst), Base.SubString{String}}) precompile(Tuple{typeof(Base.Markdown.blocktex), Base.GenericIOBuffer{Array{UInt8, 1}}, Base.Markdown.MD}) diff --git a/base/printf.jl b/base/printf.jl index 2755dc014e6c5b..d2f1f00ecc0252 100644 --- a/base/printf.jl +++ b/base/printf.jl @@ -3,7 +3,6 @@ module Printf using Base.Grisu using Base.GMP -using Base.Unicode: lowercase, textwidth, isupper ### printf formatter generation ### const SmallFloatingPoint = Union{Float64,Float32,Float16} diff --git a/base/process.jl b/base/process.jl index aec5045839af40..ca2ebb9ca5c3dd 100644 --- a/base/process.jl +++ b/base/process.jl @@ -138,7 +138,7 @@ struct FileRedirect filename::AbstractString append::Bool function FileRedirect(filename, append) - if Unicode.lowercase(filename) == (@static Sys.iswindows() ? "nul" : "/dev/null") + if lowercase(filename) == (@static Sys.iswindows() ? "nul" : "/dev/null") @warn "For portability use DevNull instead of a file redirect" maxlog=1 end new(filename, append) diff --git a/base/random/misc.jl b/base/random/misc.jl index 68abece65b1979..3ff7faea4af0d4 100644 --- a/base/random/misc.jl +++ b/base/random/misc.jl @@ -430,7 +430,7 @@ UInt128(u::UUID) = u.value let groupings = [1:8; 10:13; 15:18; 20:23; 25:36] global UUID function UUID(s::AbstractString) - s = Base.Unicode.lowercase(s) + s = lowercase(s) if !contains(s, r"^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$") throw(ArgumentError("Malformed UUID string")) diff --git a/base/regex.jl b/base/regex.jl index 0cc75f5e21de1c..716f5a379001e1 100644 --- a/base/regex.jl +++ b/base/regex.jl @@ -323,11 +323,11 @@ function _replace(io, repl_s::SubstitutionString, str, r, re) if repl[next_i] == SUB_CHAR write(io, SUB_CHAR) i = nextind(repl, next_i) - elseif Unicode.isdigit(repl[next_i]) + elseif isdigit(repl[next_i]) group = parse(Int, repl[next_i]) i = nextind(repl, next_i) while i <= e - if Unicode.isdigit(repl[i]) + if isdigit(repl[i]) group = 10group + parse(Int, repl[i]) i = nextind(repl, i) else @@ -349,7 +349,7 @@ function _replace(io, repl_s::SubstitutionString, str, r, re) end # TODO: avoid this allocation groupname = SubString(repl, groupstart, prevind(repl, i)) - if all(Unicode.isdigit, groupname) + if all(isdigit, groupname) _write_capture(io, re, parse(Int, groupname)) else group = PCRE.substring_number_from_name(re.regex, groupname) diff --git a/base/repl/LineEdit.jl b/base/repl/LineEdit.jl index 7f92d6d047b4d1..37e3574aadb243 100644 --- a/base/repl/LineEdit.jl +++ b/base/repl/LineEdit.jl @@ -9,8 +9,6 @@ import ..Terminals: raw!, width, height, cmove, getX, import Base: ensureroom, peek, show, AnyDict, position -using Base.Unicode: lowercase, uppercase, ucfirst, textwidth, isspace - abstract type TextInterface end abstract type ModeState end diff --git a/base/repl/REPL.jl b/base/repl/REPL.jl index 3858fb985902b8..1ef5c47af3b0ac 100644 --- a/base/repl/REPL.jl +++ b/base/repl/REPL.jl @@ -1090,7 +1090,7 @@ function ends_with_semicolon(line::AbstractString) else # outside of a comment, encountering anything but whitespace # means the semi-colon was internal to the expression - Base.Unicode.isspace(c) || return false + isspace(c) || return false end end return true diff --git a/base/shell.jl b/base/shell.jl index bd362bcb40a930..f172263a1fbea9 100644 --- a/base/shell.jl +++ b/base/shell.jl @@ -54,13 +54,13 @@ function shell_parse(str::AbstractString, interpolate::Bool=true; while !done(s,j) c, k = next(s,j) - if !in_single_quotes && !in_double_quotes && Unicode.isspace(c) + if !in_single_quotes && !in_double_quotes && isspace(c) update_arg(s[i:prevind(s, j)]) append_arg() j = k while !done(s,j) c, k = next(s,j) - if !Unicode.isspace(c) + if !isspace(c) i = j break end @@ -71,7 +71,7 @@ function shell_parse(str::AbstractString, interpolate::Bool=true; if done(s,k) error("\$ right before end of command") end - if Unicode.isspace(s[k]) + if isspace(s[k]) error("space not allowed right after \$") end stpos = j @@ -140,7 +140,7 @@ function print_shell_word(io::IO, word::AbstractString, special::AbstractString has_single = false has_special = false for c in word - if Unicode.isspace(c) || c=='\\' || c=='\'' || c=='"' || c=='$' || c in special + if isspace(c) || c=='\\' || c=='\'' || c=='"' || c=='$' || c in special has_special = true if c == '\'' has_single = true diff --git a/base/show.jl b/base/show.jl index 2fcdc36230db79..233ecfdacdc37c 100644 --- a/base/show.jl +++ b/base/show.jl @@ -746,7 +746,7 @@ end emphasize(io, str::AbstractString) = get(io, :color, false) ? print_with_color(Base.error_color(), io, str; bold = true) : - print(io, Unicode.uppercase(str)) + print(io, uppercase(str)) show_linenumber(io::IO, line) = print(io, "#= line ", line, " =#") show_linenumber(io::IO, line, file) = print(io, "#= ", file, ":", line, " =#") diff --git a/base/stream.jl b/base/stream.jl index 58bf399afb26b1..7aded5f67a846e 100644 --- a/base/stream.jl +++ b/base/stream.jl @@ -1073,7 +1073,7 @@ for (x, writable, unix_fd, c_symbol) in ((:STDIN, false, 0, :jl_uv_stdin), (:STDOUT, true, 1, :jl_uv_stdout), (:STDERR, true, 2, :jl_uv_stderr)) - f = Symbol("redirect_",Unicode.lowercase(string(x))) + f = Symbol("redirect_",lowercase(string(x))) _f = Symbol("_",f) @eval begin function ($_f)(stream) diff --git a/base/strings/io.jl b/base/strings/io.jl index 1e4c46124dd83f..f97dec3b61de2a 100644 --- a/base/strings/io.jl +++ b/base/strings/io.jl @@ -245,7 +245,7 @@ join(strings, delim, last) = sprint(join, strings, delim, last) ## string escaping & unescaping ## -need_full_hex(s::AbstractString, i::Int) = !done(s,i) && Unicode.isxdigit(next(s,i)[1]) +need_full_hex(s::AbstractString, i::Int) = !done(s,i) && isxdigit(next(s,i)[1]) escape_nul(s::AbstractString, i::Int) = !done(s,i) && '0' <= next(s,i)[1] <= '7' ? "\\x00" : "\\0" @@ -271,16 +271,16 @@ function escape_string(io, s::AbstractString, esc::AbstractString="") c, j = next(s,i) if c in esc print(io, '\\', c) - elseif Unicode.isascii(c) + elseif isascii(c) c == '\0' ? print(io, escape_nul(s,j)) : c == '\e' ? print(io, "\\e") : c == '\\' ? print(io, "\\\\") : c in esc ? print(io, '\\', c) : '\a' <= c <= '\r' ? print(io, '\\', "abtnvfr"[Int(c)-6]) : - Unicode.isprint(c) ? print(io, c) : + isprint(c) ? print(io, c) : print(io, "\\x", hex(c, 2)) elseif !isoverlong(c) && !ismalformed(c) - Unicode.isprint(c) ? print(io, c) : + isprint(c) ? print(io, c) : c <= '\x7f' ? print(io, "\\x", hex(c, 2)) : c <= '\uffff' ? print(io, "\\u", hex(c, need_full_hex(s, j) ? 4 : 2)) : print(io, "\\U", hex(c, need_full_hex(s, j) ? 8 : 4)) diff --git a/base/strings/strings.jl b/base/strings/strings.jl index 0edc0c4e4bba65..326fd0f2e2a2a2 100644 --- a/base/strings/strings.jl +++ b/base/strings/strings.jl @@ -3,5 +3,9 @@ include("strings/substring.jl") include("strings/search.jl") include("strings/unicode.jl") + +import .Unicode: textwidth, islower, isupper, isalpha, isdigit, isnumeric, iscntrl, ispunct, + isspace, isprint, isxdigit, lowercase, uppercase, titlecase, lcfirst, ucfirst + include("strings/util.jl") include("strings/io.jl") diff --git a/base/strings/unicode.jl b/base/strings/unicode.jl index 8447a125601b19..af4a2428306ee8 100644 --- a/base/strings/unicode.jl +++ b/base/strings/unicode.jl @@ -259,8 +259,6 @@ Give the number of columns needed to print a character. # Examples ```jldoctest -julia> using Unicode - julia> textwidth('α') 1 @@ -280,8 +278,6 @@ Give the number of columns needed to print a string. # Examples ```jldoctest -julia> using Unicode - julia> textwidth("March") 5 ``` @@ -342,8 +338,6 @@ Letter: Lowercase. # Examples ```jldoctest -julia> using Unicode - julia> islower('α') true @@ -367,8 +361,6 @@ Letter: Uppercase, or Lt, Letter: Titlecase. # Examples ```jldoctest -julia> using Unicode - julia> isupper('γ') false @@ -404,8 +396,6 @@ Tests whether a character is a decimal digit (0-9). # Examples ```jldoctest -julia> using Unicode - julia> isdigit('❤') false @@ -427,8 +417,6 @@ category Letter, i.e. a character whose category code begins with 'L'. # Examples ```jldoctest -julia> using Unicode - julia> isalpha('❤') false @@ -453,8 +441,6 @@ Use [`isdigit`](@ref) to check whether a character a decimal digit between 0 and # Examples ```jldoctest -julia> using Unicode - julia> isnumeric('௰') true @@ -470,33 +456,6 @@ false """ isnumeric(c::Char) = UTF8PROC_CATEGORY_ND <= category_code(c) <= UTF8PROC_CATEGORY_NO -""" - isalnum(c::Char) -> Bool - -Tests whether a character is alphanumeric. -A character is classified as alphabetic if it belongs to the Unicode general -category Letter or Number, i.e. a character whose category code begins with 'L' or 'N'. - -# Examples -```jldoctest -julia> using Unicode - -julia> isalnum('❤') -false - -julia> isalnum('9') -true - -julia> isalnum('α') -true -``` -""" -function isalnum(c::Char) - cat = category_code(c) - UTF8PROC_CATEGORY_LU <= cat <= UTF8PROC_CATEGORY_LO || - UTF8PROC_CATEGORY_ND <= cat <= UTF8PROC_CATEGORY_NO -end - # following C++ only control characters from the Latin-1 subset return true """ @@ -507,8 +466,6 @@ Control characters are the non-printing characters of the Latin-1 subset of Unic # Examples ```jldoctest -julia> using Unicode - julia> iscntrl('\\x01') true @@ -526,8 +483,6 @@ character whose category code begins with 'P'. # Examples ```jldoctest -julia> using Unicode - julia> ispunct('α') false @@ -551,8 +506,6 @@ category Zs. # Examples ```jldoctest -julia> using Unicode - julia> isspace('\\n') true @@ -577,8 +530,6 @@ Tests whether a character is printable, including spaces, but not a control char # Examples ```jldoctest -julia> using Unicode - julia> isprint('\\x01') false @@ -590,26 +541,6 @@ isprint(c::Char) = UTF8PROC_CATEGORY_LU <= category_code(c) <= UTF8PROC_CATEGORY # true in principal if a printer would use ink -""" - isgraph(c::Char) -> Bool - -Tests whether a character is printable, and not a space. -Any character that would cause a printer to use ink should be -classified with `isgraph(c)==true`. - -# Examples -```jldoctest -julia> using Unicode - -julia> isgraph('\\x01') -false - -julia> isgraph('A') -true -``` -""" -isgraph(c::Char) = UTF8PROC_CATEGORY_LU <= category_code(c) <= UTF8PROC_CATEGORY_SO - """ isxdigit(c::Char) -> Bool @@ -618,8 +549,6 @@ include `x` (as in the standard `0x` prefix). # Examples ```jldoctest -julia> using Unicode - julia> isxdigit('a') true @@ -638,8 +567,6 @@ Return `s` with all characters converted to uppercase. # Examples ```jldoctest -julia> using Unicode - julia> uppercase("Julia") "JULIA" ``` @@ -653,8 +580,6 @@ Return `s` with all characters converted to lowercase. # Examples ```jldoctest -julia> using Unicode - julia> lowercase("STRINGS AND THINGS") "strings and things" ``` diff --git a/base/util.jl b/base/util.jl index 3e0377ba58e315..e2a32a511795a2 100644 --- a/base/util.jl +++ b/base/util.jl @@ -423,7 +423,7 @@ function getpass(prompt::AbstractString) ccall(:_getch, UInt8, ()) # ignore function/arrow keys elseif c == UInt8('\b') && plen > 0 plen -= 1 # delete last character on backspace - elseif !Unicode.iscntrl(Char(c)) && plen < 128 + elseif !iscntrl(Char(c)) && plen < 128 p[plen += 1] = c end end diff --git a/doc/src/base/strings.md b/doc/src/base/strings.md index 1175c11e3268d5..e6c3e7b284c99e 100644 --- a/doc/src/base/strings.md +++ b/doc/src/base/strings.md @@ -48,6 +48,11 @@ Base.startswith Base.endswith Base.first(::AbstractString, ::Integer) Base.last(::AbstractString, ::Integer) +Base.uppercase +Base.lowercase +Base.titlecase +Base.ucfirst +Base.lcfirst Base.join Base.chop Base.chomp @@ -55,6 +60,18 @@ Base.thisind Base.nextind Base.prevind Base.Random.randstring +Base.textwidth +Base.isalpha +Base.isascii +Base.iscntrl +Base.isdigit +Base.islower +Base.isnumeric +Base.isprint +Base.ispunct +Base.isspace +Base.isupper +Base.isxdigit Core.Symbol Base.escape_string Base.unescape_string diff --git a/doc/src/manual/unicode-input.md b/doc/src/manual/unicode-input.md index 57f9894e7423ec..0952f6324b8310 100644 --- a/doc/src/manual/unicode-input.md +++ b/doc/src/manual/unicode-input.md @@ -37,7 +37,7 @@ function unicode_data() for line in readlines(unidata) id, name, desc = split(line, ";")[[1, 2, 11]] codepoint = parse(UInt32, "0x$id") - names[codepoint] = Base.Unicode.titlecase(Base.Unicode.lowercase( + names[codepoint] = titlecase(lowercase( name == "" ? desc : desc == "" ? name : "$name / $desc")) end end @@ -61,7 +61,7 @@ function table_entries(completions, unicode_dict) for (chars, inputs) in sort!(collect(completions), by = first) code_points, unicode_names, characters = String[], String[], String[] for char in chars - push!(code_points, "U+$(Base.Unicode.uppercase(hex(char, 5)))") + push!(code_points, "U+$(uppercase(hex(char, 5)))") push!(unicode_names, get(unicode_dict, UInt32(char), "(No Unicode name)")) push!(characters, isempty(characters) ? fix_combining_chars(char) : "$char") end diff --git a/stdlib/Dates/src/parse.jl b/stdlib/Dates/src/parse.jl index 5f8698291ca369..1b0e4165394c0b 100644 --- a/stdlib/Dates/src/parse.jl +++ b/stdlib/Dates/src/parse.jl @@ -16,7 +16,7 @@ function character_codes(directives::SimpleVector) return letters end -genvar(t::DataType) = Symbol(Base.Unicode.lowercase(string(Base.datatype_name(t)))) +genvar(t::DataType) = Symbol(lowercase(string(Base.datatype_name(t)))) """ tryparsenext_core(str::AbstractString, pos::Int, len::Int, df::DateFormat, raise=false) @@ -183,7 +183,7 @@ end max_pos = maxchars <= 0 ? len : min(len, nextind(str, i, maxchars-1)) @inbounds while i <= max_pos c, ii = next(str, i) - if Base.Unicode.isalpha(c) + if isalpha(c) word_end = i else break diff --git a/stdlib/Dates/src/periods.jl b/stdlib/Dates/src/periods.jl index 1a203ad3fbcde3..946aee2fe5ef22 100644 --- a/stdlib/Dates/src/periods.jl +++ b/stdlib/Dates/src/periods.jl @@ -8,7 +8,7 @@ value(x::Period) = x.value # The following definitions are for Period-specific safety for period in (:Year, :Month, :Week, :Day, :Hour, :Minute, :Second, :Millisecond, :Microsecond, :Nanosecond) period_str = string(period) - accessor_str = Base.Unicode.lowercase(period_str) + accessor_str = lowercase(period_str) # Convenience method for show() @eval _units(x::$period) = " " * $accessor_str * (abs(value(x)) == 1 ? "" : "s") # periodisless diff --git a/stdlib/Dates/src/query.jl b/stdlib/Dates/src/query.jl index 801431329524bc..88806673cc1577 100644 --- a/stdlib/Dates/src/query.jl +++ b/stdlib/Dates/src/query.jl @@ -22,7 +22,7 @@ function locale_dict(names::Vector{<:AbstractString}) for i in 1:length(names) name = names[i] result[name] = i - result[Base.Unicode.lowercase(name)] = i + result[lowercase(name)] = i end return result end @@ -72,7 +72,7 @@ for (fn, field) in zip( # a case-sensitive lookup first value = get(locale.$field, word, 0) if value == 0 - value = get(locale.$field, Base.Unicode.lowercase(word), 0) + value = get(locale.$field, lowercase(word), 0) end value end diff --git a/stdlib/Dates/test/io.jl b/stdlib/Dates/test/io.jl index 8ddf5367229dee..ba30b84cd20056 100644 --- a/stdlib/Dates/test/io.jl +++ b/stdlib/Dates/test/io.jl @@ -297,7 +297,7 @@ end @test Dates.format(Dates.Date(2009, 12, 1), f) == "01Dec2009" f = "duy" globex = ["f", "g", "h", "j", "k", "m", "n", "q", "u", "v", "x", "z"] - locale = Dates.DateLocale(globex, map(Base.Unicode.uppercase, globex), globex[1:7], globex[1:7]) + locale = Dates.DateLocale(globex, map(uppercase, globex), globex[1:7], globex[1:7]) @test Dates.Date("1F4", f; locale=locale) + Dates.Year(2010) == Dates.Date(2014, 1, 1) @test Dates.format(Dates.Date(2014, 1, 1), f; locale=locale) == "1F4" diff --git a/stdlib/Distributed/src/Distributed.jl b/stdlib/Distributed/src/Distributed.jl index 31e2a8659dfbeb..71fafdd7de280b 100644 --- a/stdlib/Distributed/src/Distributed.jl +++ b/stdlib/Distributed/src/Distributed.jl @@ -17,7 +17,6 @@ using Base: Process, Semaphore, JLOptions, AnyDict, buffer_writes, wait_connecte binding_module, notify_error, atexit, julia_exename, julia_cmd, AsyncGenerator, acquire, release, invokelatest, shell_escape_posixly, uv_error, coalesce, notnothing -using Base.Unicode: isdigit, isnumeric # NOTE: clusterserialize.jl imports additional symbols from Base.Serializer for use diff --git a/stdlib/Distributed/test/distributed_exec.jl b/stdlib/Distributed/test/distributed_exec.jl index 8365d4ff904af6..18d886a2647e11 100644 --- a/stdlib/Distributed/test/distributed_exec.jl +++ b/stdlib/Distributed/test/distributed_exec.jl @@ -532,7 +532,6 @@ generic_map_tests(pmap_fallback) # pmap with various types. Test for equivalence with map run_map_equivalence_tests(pmap) -using Base.Unicode: uppercase @test pmap(uppercase, "Hello World!") == map(uppercase, "Hello World!") diff --git a/stdlib/Unicode/docs/src/index.md b/stdlib/Unicode/docs/src/index.md index 4f519aa0bc05e5..aba9d80c3e8b54 100644 --- a/stdlib/Unicode/docs/src/index.md +++ b/stdlib/Unicode/docs/src/index.md @@ -4,22 +4,4 @@ Unicode.isassigned Unicode.normalize Unicode.graphemes -Unicode.uppercase -Unicode.lowercase -Unicode.titlecase -Unicode.ucfirst -Unicode.lcfirst -Unicode.textwidth -Unicode.isalnum -Unicode.isalpha -Unicode.iscntrl -Unicode.isdigit -Unicode.isgraph -Unicode.islower -Unicode.isnumeric -Unicode.isprint -Unicode.ispunct -Unicode.isspace -Unicode.isupper -Unicode.isxdigit ``` diff --git a/stdlib/Unicode/src/Unicode.jl b/stdlib/Unicode/src/Unicode.jl index e55a8f6cc39ef0..9a1ce248dc95ac 100644 --- a/stdlib/Unicode/src/Unicode.jl +++ b/stdlib/Unicode/src/Unicode.jl @@ -4,19 +4,12 @@ __precompile__(true) module Unicode -using Base.Unicode: normalize, graphemes, isassigned, textwidth, isvalid, - islower, isupper, isalpha, isdigit, isxdigit, isnumeric, isalnum, - iscntrl, ispunct, isspace, isprint, isgraph, - lowercase, uppercase, titlecase, lcfirst, ucfirst, iscased +using Base.Unicode: normalize, graphemes, isassigned, iscased -export graphemes, textwidth, isvalid, - islower, isupper, isalpha, isdigit, isxdigit, isnumeric, isalnum, - iscntrl, ispunct, isspace, isprint, isgraph, - lowercase, uppercase, titlecase, lcfirst, ucfirst +export graphemes # BEGIN 0.7 deprecations -@deprecate isnumber(c::Char) Unicode.isnumeric(c) @deprecate is_assigned_char(c::Char) Unicode.isassigned(c) @deprecate normalize_string(s::AbstractString, nf::Symbol; kwargs...) Unicode.normalize(s, nf; kwargs...) @deprecate normalize_string(s::AbstractString; kwargs...) Unicode.normalize(s; kwargs...) diff --git a/stdlib/Unicode/test/runtests.jl b/stdlib/Unicode/test/runtests.jl index 5a5b83eb12b877..aab3b9ae0f761d 100644 --- a/stdlib/Unicode/test/runtests.jl +++ b/stdlib/Unicode/test/runtests.jl @@ -131,7 +131,7 @@ end alnums=vcat(alphas,anumber,unumber) for c in alnums - @test isalnum(c) == true + @test isalpha(c) || isnumeric(c) @test ispunct(c) == false end @@ -143,12 +143,11 @@ end for c in vcat(apunct,upunct) @test ispunct(c) == true - @test isalnum(c) == false + @test !isalpha(c) && !isnumeric(c) end for c in vcat(alnums,asymbol,usymbol,apunct,upunct) @test isprint(c) == true - @test isgraph(c) == true @test isspace(c) == false @test iscntrl(c) == false end @@ -165,13 +164,11 @@ end for c in vcat(aspace,uspace) @test isspace(c) == true @test isprint(c) == true - @test isgraph(c) == false end for c in vcat(acntrl_space) @test isspace(c) == true @test isprint(c) == false - @test isgraph(c) == false end @test isspace(ZWSPACE) == false # zero-width space @@ -182,23 +179,20 @@ end for c in vcat(acontrol, acntrl_space, latincontrol) @test iscntrl(c) == true - @test isalnum(c) == false + @test !isalpha(c) && !isnumeric(c) @test isprint(c) == false - @test isgraph(c) == false end for c in ucontrol #non-latin1 controls if c!=Char(0x0085) @test iscntrl(c) == false @test isspace(c) == false - @test isalnum(c) == false + @test !isalpha(c) && !isnumeric(c) @test isprint(c) == false - @test isgraph(c) == false end end @test all(isspace," \t \n \r ") - @test !all(isgraph," \t \n \r ") @test !all(isprint," \t \n \r ") @test !all(isalpha," \t \n \r ") @test !all(isnumeric," \t \n \r ") @@ -206,7 +200,6 @@ end @test !all(isspace,"ΣβΣβ") @test all(isalpha,"ΣβΣβ") - @test all(isgraph,"ΣβΣβ") @test all(isprint,"ΣβΣβ") @test !all(isupper,"ΣβΣβ") @test !all(islower,"ΣβΣβ") @@ -216,7 +209,6 @@ end @test all(isnumeric,"23435") @test all(isdigit,"23435") - @test all(isalnum,"23435") @test !all(isalpha,"23435") @test all(iscntrl,string(Char(0x0080))) @test all(ispunct, "‡؟჻") diff --git a/test/dict.jl b/test/dict.jl index d3df55dab77a14..5439106698106b 100644 --- a/test/dict.jl +++ b/test/dict.jl @@ -282,7 +282,7 @@ end Base.show(io, MIME("text/plain"), d) out = split(String(take!(s)),'\n') for line in out[2:end] - @test Base.Unicode.textwidth(line) <= cols + @test textwidth(line) <= cols end @test length(out) <= rows @@ -292,7 +292,7 @@ end Base.show(io, MIME("text/plain"), f(d)) out = split(String(take!(s)),'\n') for line in out[2:end] - @test Base.Unicode.textwidth(line) <= cols + @test textwidth(line) <= cols end @test length(out) <= rows end diff --git a/test/docs.jl b/test/docs.jl index 295d116216576f..ed143bd6f2b35c 100644 --- a/test/docs.jl +++ b/test/docs.jl @@ -953,7 +953,7 @@ for (line, expr) in Pair[ "\"...\"" => "...", "r\"...\"" => Expr(:macrocall, Symbol("@r_str"), LineNumberNode(1, :none), "...") ] - @test Docs.helpmode(line) == Expr(:macrocall, Expr(:., Expr(:., :Base, QuoteNode(:Docs)), QuoteNode(Symbol("@repl"))), LineNumberNode(116, doc_util_path), STDOUT, expr) + @test Docs.helpmode(line) == Expr(:macrocall, Expr(:., Expr(:., :Base, QuoteNode(:Docs)), QuoteNode(Symbol("@repl"))), LineNumberNode(115, doc_util_path), STDOUT, expr) buf = IOBuffer() @test eval(Base, Docs.helpmode(buf, line)) isa Union{Base.Markdown.MD,Nothing} end @@ -985,8 +985,8 @@ dynamic_test.x = "test 2" @test @doc(dynamic_test) == "test 2 Union{}" @test @doc(dynamic_test(::String)) == "test 2 Tuple{String}" -@test Docs._repl(:(dynamic_test(1.0))) == Expr(:escape, Expr(:macrocall, Symbol("@doc"), LineNumberNode(197, doc_util_path), :(dynamic_test(::typeof(1.0))))) -@test Docs._repl(:(dynamic_test(::String))) == Expr(:escape, Expr(:macrocall, Symbol("@doc"), LineNumberNode(197, doc_util_path), :(dynamic_test(::String)))) +@test Docs._repl(:(dynamic_test(1.0))) == Expr(:escape, Expr(:macrocall, Symbol("@doc"), LineNumberNode(196, doc_util_path), :(dynamic_test(::typeof(1.0))))) +@test Docs._repl(:(dynamic_test(::String))) == Expr(:escape, Expr(:macrocall, Symbol("@doc"), LineNumberNode(196, doc_util_path), :(dynamic_test(::String)))) diff --git a/test/iobuffer.jl b/test/iobuffer.jl index 60b459fccb20fe..d0d9a8bf602f11 100644 --- a/test/iobuffer.jl +++ b/test/iobuffer.jl @@ -258,7 +258,6 @@ let io = IOBuffer() end # skipchars -using Base.Unicode: isspace let io = IOBuffer("") @test eof(skipchars(io, isspace)) @@ -279,7 +278,7 @@ let for char in ['@','߷','࿊','𐋺'] io = IOBuffer("alphabeticalstuff$char") - @test !eof(skipchars(io, Base.Unicode.isalpha)) + @test !eof(skipchars(io, isalpha)) @test read(io, Char) == char end end diff --git a/test/iostream.jl b/test/iostream.jl index 67a0e7d90af0a4..31026b753d1733 100644 --- a/test/iostream.jl +++ b/test/iostream.jl @@ -1,7 +1,6 @@ # This file is a part of Julia. License is MIT: https://julialang.org/license # Test skipchars for IOStreams -using Base.Unicode: isspace mktemp() do path, file function append_to_file(str) mark(file) @@ -35,7 +34,7 @@ mktemp() do path, file for (byte,char) in zip(1:4, ('@','߷','࿊','𐋺')) append_to_file("abcdef$char") @test Base.codelen(char) == byte - @test !eof(skipchars(file, Base.Unicode.isalpha)) + @test !eof(skipchars(file, isalpha)) @test read(file, Char) == char end end diff --git a/test/libgit2.jl b/test/libgit2.jl index c1251ac28d008c..aab5785a1ae7dd 100644 --- a/test/libgit2.jl +++ b/test/libgit2.jl @@ -2,7 +2,6 @@ isdefined(Main, :TestHelpers) || @eval Main include(joinpath(@__DIR__, "TestHelpers.jl")) import Main.TestHelpers: challenge_prompt -using Base.Unicode: lowercase const LIBGIT2_MIN_VER = v"0.23.0" const LIBGIT2_HELPER_PATH = joinpath(@__DIR__, "libgit2-helpers.jl") diff --git a/test/operators.jl b/test/operators.jl index 96c0f538ad2bf9..335691a2e3bc5d 100644 --- a/test/operators.jl +++ b/test/operators.jl @@ -106,12 +106,12 @@ Base.promote_rule(::Type{T19714}, ::Type{Int}) = T19714 # pr #17155 @testset "function composition" begin - @test (Base.Unicode.uppercase∘hex)(239487) == "3A77F" + @test (uppercase∘hex)(239487) == "3A77F" end @testset "function negation" begin str = randstring(20) - @test filter(!Base.Unicode.isupper, str) == replace(str, r"[A-Z]" => "") - @test filter(!Base.Unicode.islower, str) == replace(str, r"[a-z]" => "") + @test filter(!isupper, str) == replace(str, r"[A-Z]" => "") + @test filter(!islower, str) == replace(str, r"[a-z]" => "") end # issue #19891 diff --git a/test/perf/kernel/json.jl b/test/perf/kernel/json.jl index 44917d6b86d447..8f992508614b3d 100644 --- a/test/perf/kernel/json.jl +++ b/test/perf/kernel/json.jl @@ -69,7 +69,7 @@ function parse_json(strng::AbstractString) end function skip_whitespace() - while pos <= len && Base.Unicode.isspace(strng[pos]) + while pos <= len && isspace(strng[pos]) pos = pos + 1 end end diff --git a/test/perf/perfgeneric.jl b/test/perf/perfgeneric.jl index 4fef6051e42ae2..4e7dba0fa80514 100644 --- a/test/perf/perfgeneric.jl +++ b/test/perf/perfgeneric.jl @@ -3,6 +3,6 @@ #Generic benchmark driver for (testfunc, testname, longtestname, problem_sizes) in testdata for (n, t, size) in problem_sizes - @timeit testfunc(n, t) string(testname,"_",size) string(Base.Unicode.uppercase(size[1]),size[2:end]," ",longtestname," test") + @timeit testfunc(n, t) string(testname,"_",size) string(uppercase(size[1]),size[2:end]," ",longtestname," test") end end diff --git a/test/perf/shootout/k_nucleotide.jl b/test/perf/shootout/k_nucleotide.jl index a070e79c97719e..d132efe2100495 100644 --- a/test/perf/shootout/k_nucleotide.jl +++ b/test/perf/shootout/k_nucleotide.jl @@ -70,7 +70,7 @@ function k_nucleotide(infile="knucleotide-input.txt") i, j = 1, 1 while i <= length(data) if data[i] != '\n' - data[j] = Base.Unicode.uppercase(data[i]) + data[j] = uppercase(data[i]) j += 1 end i += 1 diff --git a/test/perf/spell/perf.jl b/test/perf/spell/perf.jl index 687b9243ac99ad..8fa1e8426f32b4 100644 --- a/test/perf/spell/perf.jl +++ b/test/perf/spell/perf.jl @@ -15,7 +15,7 @@ include("../perfutil.jl") -words(text) = eachmatch(r"[a-z]+", Base.Unicode.lowercase(text)) +words(text) = eachmatch(r"[a-z]+", lowercase(text)) function train(features) model = Dict{AbstractString, Int}() diff --git a/test/strings/basic.jl b/test/strings/basic.jl index aba06f60dd7694..0d92f69292fa59 100644 --- a/test/strings/basic.jl +++ b/test/strings/basic.jl @@ -233,7 +233,7 @@ end @test done(eachindex("foobar"),7) @test eltype(Base.EachStringIndex) == Int - @test map(Base.Unicode.uppercase, "foó") == "FOÓ" + @test map(uppercase, "foó") == "FOÓ" @test nextind("fóobar", 0, 3) == 4 @test Symbol(gstr) == Symbol("12") @@ -293,6 +293,8 @@ end @test tryparse(Float32, "32o") === nothing end +import Unicode + @testset "issue #10994: handle embedded NUL chars for string parsing" begin for T in [BigInt, Int8, UInt8, Int16, UInt16, Int32, UInt32, Int64, UInt64, Int128, UInt128] @test_throws ArgumentError parse(T, "1\0") @@ -300,7 +302,7 @@ end for T in [BigInt, Int8, UInt8, Int16, UInt16, Int32, UInt32, Int64, UInt64, Int128, UInt128, Float64, Float32] @test tryparse(T, "1\0") === nothing end - let s = Base.Unicode.normalize("tést",:NFKC) + let s = Unicode.normalize("tést",:NFKC) @test unsafe_string(Base.unsafe_convert(Cstring, Base.cconvert(Cstring, s))) == s @test unsafe_string(Base.unsafe_convert(Cstring, Symbol(s))) == s end diff --git a/test/strings/io.jl b/test/strings/io.jl index 79476810c3329e..28f7d9bdf5e4bc 100644 --- a/test/strings/io.jl +++ b/test/strings/io.jl @@ -66,14 +66,14 @@ cp, ch, st = cx[i,:] @test cp == convert(UInt32, ch) @test string(ch) == unescape_string(st) - if isascii(ch) || !Base.Unicode.isprint(ch) + if isascii(ch) || !isprint(ch) @test st == escape_string(string(ch)) end for j = 1:size(cx,1) local str = string(ch, cx[j,2]) @test str == unescape_string(escape_string(str)) end - @test repr(ch) == "'$(Base.Unicode.isprint(ch) ? ch : st)'" + @test repr(ch) == "'$(isprint(ch) ? ch : st)'" end for i = 0:0x7f, p = ["","\0","x","xxx","\x7f","\uFF","\uFFF", diff --git a/test/strings/util.jl b/test/strings/util.jl index cb1a09a6cb2d70..3ac1eb7edbdd12 100644 --- a/test/strings/util.jl +++ b/test/strings/util.jl @@ -242,7 +242,7 @@ end @test replace("ḟøøƀäṙḟøø", r"(ḟø|ƀä)" => "xx") == "xxøxxṙxxø" @test replace("ḟøøƀäṙḟøø", r"(ḟøø|ƀä)" => "ƀäṙ") == "ƀäṙƀäṙṙƀäṙ" - @test replace("foo", "oo" => Base.Unicode.uppercase) == "fOO" + @test replace("foo", "oo" => uppercase) == "fOO" # Issue 13332 @test replace("abc", 'b' => 2.1) == "a2.1c"