Skip to content

Commit 234ad9e

Browse files
committed
move case functions and char predicates back to Base
fixes #25394
1 parent b6b6821 commit 234ad9e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+118
-218
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ The steps required to add a new docstring are listed below:
174174
Examples written within docstrings can be used as testcases known as "doctests" by annotating code blocks with `jldoctest`.
175175

176176
```jldoctest
177-
julia> Unicode.uppercase("Docstring test")
177+
julia> uppercase("Docstring test")
178178
"DOCSTRING TEST"
179179
```
180180

NEWS.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -864,10 +864,8 @@ Deprecated or removed
864864
[KahanSummation](https://github.com/JuliaMath/KahanSummation.jl) package ([#24869]).
865865

866866
* Unicode-related string functions have been moved to the new `Unicode` standard
867-
library module ([#25021]). This applies to `normalize_string`, `graphemes`,
868-
`is_assigned_char`, `textwidth`, `islower`, `isupper`, `isalpha`,
869-
`isdigit`, `isxdigit`, `isnumber`, `isalnum`, `iscntrl`, `ispunct`, `isspace`,
870-
`isprint`, `isgraph`, `lowercase`, `uppercase`, `titlecase`, `lcfirst` and `ucfirst`.
867+
library module ([#25021]). This applies to `normalize_string`, `graphemes`, and
868+
`is_assigned_char`
871869

872870
* The functions `eigs` and `svds` have been moved to the `IterativeEigensolvers` standard
873871
library module ([#24714]).

base/arrayshow.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ function print_matrix(io::IO, X::AbstractVecOrMat,
166166
screenwidth -= length(pre) + length(post)
167167
presp = repeat(" ", length(pre)) # indent each row to match pre string
168168
postsp = ""
169-
@assert Unicode.textwidth(hdots) == Unicode.textwidth(ddots)
169+
@assert textwidth(hdots) == textwidth(ddots)
170170
sepsize = length(sep)
171171
rowsA, colsA = axes(X,1), axes(X,2)
172172
m, n = length(rowsA), length(colsA)

base/char.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ function show(io::IO, c::Char)
127127
(u <<= 8) == 0 && break
128128
end
129129
write(io, 0x27)
130-
elseif Unicode.isprint(c)
130+
elseif isprint(c)
131131
write(io, 0x27, c, 0x27)
132132
else # unprintable, well-formed, non-overlong Unicode
133133
u = UInt32(c)

base/deprecated.jl

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2801,23 +2801,10 @@ end
28012801
@deprecate_moved normalize_string "Unicode" true true
28022802
@deprecate_moved graphemes "Unicode" true true
28032803
@deprecate_moved is_assigned_char "Unicode" true true
2804-
@deprecate_moved textwidth "Unicode" true true
2805-
@deprecate_moved islower "Unicode" true true
2806-
@deprecate_moved isupper "Unicode" true true
2807-
@deprecate_moved isalpha "Unicode" true true
2808-
@deprecate_moved isdigit "Unicode" true true
2809-
@deprecate_moved isnumber "Unicode" true true
2810-
@deprecate_moved isalnum "Unicode" true true
2811-
@deprecate_moved iscntrl "Unicode" true true
2812-
@deprecate_moved ispunct "Unicode" true true
2813-
@deprecate_moved isspace "Unicode" true true
2814-
@deprecate_moved isprint "Unicode" true true
2815-
@deprecate_moved isgraph "Unicode" true true
2816-
@deprecate_moved lowercase "Unicode" true true
2817-
@deprecate_moved uppercase "Unicode" true true
2818-
@deprecate_moved titlecase "Unicode" true true
2819-
@deprecate_moved lcfirst "Unicode" true true
2820-
@deprecate_moved ucfirst "Unicode" true true
2804+
2805+
@deprecate isalnum(c::Char) isalpha(c) || isnumeric(c)
2806+
@deprecate isgraph(c::Char) isprint(c) && !isspace(c)
2807+
@deprecate isnumber(c::Char) isnumeric(c)
28212808

28222809
# PR #24647
28232810
@deprecate_binding Complex32 ComplexF16

base/dict.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# This file is a part of Julia. License is MIT: https://julialang.org/license
22

33
function _truncate_at_width_or_chars(str, width, chars="", truncmark="")
4-
truncwidth = Unicode.textwidth(truncmark)
4+
truncwidth = textwidth(truncmark)
55
(width <= 0 || width < truncwidth) && return ""
66

77
wid = truncidx = lastidx = 0
88
idx = start(str)
99
while !done(str, idx)
1010
lastidx = idx
1111
c, idx = next(str, idx)
12-
wid += Unicode.textwidth(c)
12+
wid += textwidth(c)
1313
wid >= width - truncwidth && truncidx == 0 && (truncidx = lastidx)
1414
(wid >= width || c in chars) && break
1515
end

base/docs/utils.jl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
# Text / HTML objects
44

55
import Base: print, show, ==, hash
6-
using Base.Unicode
76

87
export HTML, @html_str
98

@@ -222,8 +221,8 @@ function matchinds(needle, haystack; acronym = false)
222221
for (i, char) in enumerate(haystack)
223222
isempty(chars) && break
224223
while chars[1] == ' ' popfirst!(chars) end # skip spaces
225-
if Unicode.lowercase(char) == Unicode.lowercase(chars[1]) &&
226-
(!acronym || !Unicode.isalpha(lastc))
224+
if lowercase(char) == lowercase(chars[1]) &&
225+
(!acronym || !isalpha(lastc))
227226
push!(is, i)
228227
popfirst!(chars)
229228
end

base/exports.jl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,19 @@ export
704704
hex2bytes!,
705705
info,
706706
isascii,
707+
isalpha,
708+
isascii,
709+
iscntrl,
710+
isdigit,
711+
islower,
712+
isnumeric,
713+
isprint,
714+
ispunct,
715+
isspace,
716+
isupper,
717+
isxdigit,
718+
lcfirst,
719+
lowercase,
707720
isvalid,
708721
join,
709722
logging,
@@ -735,9 +748,13 @@ export
735748
string,
736749
strip,
737750
summary,
751+
textwidth,
738752
thisind,
753+
titlecase,
739754
transcode,
755+
ucfirst,
740756
unescape_string,
757+
uppercase,
741758
warn,
742759

743760
# logging frontend

base/interactiveutil.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ function edit(path::AbstractString, line::Integer=0)
5151
cmd = line != 0 ? `$command $path -l $line` : `$command $path`
5252
elseif startswith(name, "subl") || startswith(name, "atom")
5353
cmd = line != 0 ? `$command $path:$line` : `$command $path`
54-
elseif name == "code" || (Sys.iswindows() && Unicode.uppercase(name) == "CODE.EXE")
54+
elseif name == "code" || (Sys.iswindows() && uppercase(name) == "CODE.EXE")
5555
cmd = line != 0 ? `$command -g $path:$line` : `$command -g $path`
5656
elseif startswith(name, "notepad++")
5757
cmd = line != 0 ? `$command $path -n$line` : `$command $path`

base/io.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -924,8 +924,6 @@ characters from that character until the start of the next line are ignored.
924924
julia> buf = IOBuffer(" text")
925925
IOBuffer(data=UInt8[...], readable=true, writable=false, seekable=true, append=false, size=8, maxsize=Inf, ptr=1, mark=-1)
926926
927-
julia> using Unicode
928-
929927
julia> skipchars(buf, isspace)
930928
IOBuffer(data=UInt8[...], readable=true, writable=false, seekable=true, append=false, size=8, maxsize=Inf, ptr=5, mark=-1)
931929

0 commit comments

Comments
 (0)