Skip to content

Commit 006c581

Browse files
committed
Rename isupper, islower, ucfirst and lcfirst
Spell "uppercase" and "lowercase" in full for consistency with uppercase and lowercase functions.
1 parent 7beb110 commit 006c581

File tree

14 files changed

+76
-67
lines changed

14 files changed

+76
-67
lines changed

HISTORY.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ Deprecated or removed
516516
[#18558], [#19711], [#19712], [#19791], [#19802], [#19931], [#20543], [#20228]).
517517
518518
* All methods of character predicates (`isalnum`, `isalpha`, `iscntrl`, `isdigit`,
519-
`isnumber`, `isgraph`, `islower`, `isprint`, `ispunct`, `isspace`, `isupper`,
519+
`isnumber`, `isgraph`, `islowercase`, `isprint`, `ispunct`, `isspace`, `isuppercase`,
520520
`isxdigit`) that accept `AbstractStrings` have been deprecated in favor of `all`.
521521
For example, `isnumber("123")` should now be expressed `all(isnumber, "123")`
522522
([#20342]).
@@ -1369,7 +1369,7 @@ Library improvements
13691369
13701370
* `graphemes(s)` returns an iterator over grapheme substrings of `s` ([#9261]).
13711371
1372-
* Character predicates such as `islower()`, `isspace()`, etc. use
1372+
* Character predicates such as `islowercase()`, `isspace()`, etc. use
13731373
utf8proc to provide uniform cross-platform behavior and
13741374
up-to-date, locale-independent support for Unicode standards
13751375
([#5939]).

NEWS.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -1099,6 +1099,9 @@ Deprecated or removed
10991099
`show(IOContext(io, :compact => true), x...)` ([#26080]).
11001100
Use `sprint(show, x..., context=:compact => true)` instead of `sprint(showcompact, x...)`.
11011101

1102+
* `isupper`, `islower`, `ucfirst` and `lcfirst` have been deprecated in favor of `isuppercase`,
1103+
`islowercase`, `uppercasefirst` and `lowercasefirst`, respectively ([#26442]).
1104+
11021105
Command-line option changes
11031106
---------------------------
11041107

@@ -1396,4 +1399,5 @@ Command-line option changes
13961399
[#26009]: https://github.com/JuliaLang/julia/issues/26009
13971400
[#26071]: https://github.com/JuliaLang/julia/issues/26071
13981401
[#26080]: https://github.com/JuliaLang/julia/issues/26080
1399-
[#26149]: https://github.com/JuliaLang/julia/issues/26149
1402+
[#26149]: https://github.com/JuliaLang/julia/issues/26149
1403+
[#26442]: https://github.com/JuliaLang/julia/issues/26442

base/deprecated.jl

+5
Original file line numberDiff line numberDiff line change
@@ -1518,6 +1518,11 @@ end
15181518
@deprecate showcompact(io, x) show(IOContext(io, :compact => true), x)
15191519
@deprecate sprint(::typeof(showcompact), args...) sprint(show, args...; context=:compact => true)
15201520

1521+
@deprecate isupper isuppercase
1522+
@deprecate islower islowercase
1523+
@deprecate ucfirst uppercasefirst
1524+
@deprecate lcfirst lowercasefirst
1525+
15211526
# END 0.7 deprecations
15221527

15231528
# BEGIN 1.0 deprecations

base/exports.jl

+4-4
Original file line numberDiff line numberDiff line change
@@ -574,15 +574,15 @@ export
574574
isascii,
575575
iscntrl,
576576
isdigit,
577-
islower,
577+
islowercase,
578578
isnumeric,
579579
isprint,
580580
ispunct,
581581
isspace,
582-
isupper,
582+
isuppercase,
583583
isxdigit,
584-
lcfirst,
585584
lowercase,
585+
lowercasefirst,
586586
isvalid,
587587
join,
588588
lpad,
@@ -606,9 +606,9 @@ export
606606
thisind,
607607
titlecase,
608608
transcode,
609-
ucfirst,
610609
unescape_string,
611610
uppercase,
611+
uppercasefirst,
612612

613613
# text output
614614
IOContext,

base/printf.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ function gen_e(flags::String, width::Int, precision::Int, c::Char, inside_g::Boo
413413
blk = ifblk.args[2]
414414
push!(blk.args, :((len, pt, neg) = args))
415415
push!(blk.args, :(exp = pt-1))
416-
expmark = isupper(c) ? "E" : "e"
416+
expmark = isuppercase(c) ? "E" : "e"
417417
if precision==0 && '#' in flags
418418
expmark = string(".",expmark)
419419
end

base/strings/strings.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ include("strings/substring.jl")
44
include("strings/search.jl")
55
include("strings/unicode.jl")
66

7-
import .Unicode: textwidth, islower, isupper, isalpha, isdigit, isnumeric, iscntrl, ispunct,
8-
isspace, isprint, isxdigit, lowercase, uppercase, titlecase, lcfirst, ucfirst
7+
import .Unicode: textwidth, islowercase, isuppercase, isalpha, isdigit, isnumeric, iscntrl, ispunct,
8+
isspace, isprint, isxdigit, lowercase, uppercase, titlecase, lowercasefirst, uppercasefirst
99

1010
include("strings/util.jl")
1111
include("strings/io.jl")

base/strings/unicode.jl

+19-19
Original file line numberDiff line numberDiff line change
@@ -268,48 +268,48 @@ isassigned(c) = UTF8PROC_CATEGORY_CN < category_code(c) <= UTF8PROC_CATEGORY_CO
268268
## libc character class predicates ##
269269

270270
"""
271-
islower(c::AbstractChar) -> Bool
271+
islowercase(c::AbstractChar) -> Bool
272272
273273
Tests whether a character is a lowercase letter.
274274
A character is classified as lowercase if it belongs to Unicode category Ll,
275275
Letter: Lowercase.
276276
277277
# Examples
278278
```jldoctest
279-
julia> islower('α')
279+
julia> islowercase('α')
280280
true
281281
282-
julia> islower('Γ')
282+
julia> islowercase('Γ')
283283
false
284284
285-
julia> islower('❤')
285+
julia> islowercase('❤')
286286
false
287287
```
288288
"""
289-
islower(c::AbstractChar) = category_code(c) == UTF8PROC_CATEGORY_LL
289+
islowercase(c::AbstractChar) = category_code(c) == UTF8PROC_CATEGORY_LL
290290

291291
# true for Unicode upper and mixed case
292292

293293
"""
294-
isupper(c::AbstractChar) -> Bool
294+
isuppercase(c::AbstractChar) -> Bool
295295
296296
Tests whether a character is an uppercase letter.
297297
A character is classified as uppercase if it belongs to Unicode category Lu,
298298
Letter: Uppercase, or Lt, Letter: Titlecase.
299299
300300
# Examples
301301
```jldoctest
302-
julia> isupper('γ')
302+
julia> isuppercase('γ')
303303
false
304304
305-
julia> isupper('Γ')
305+
julia> isuppercase('Γ')
306306
true
307307
308-
julia> isupper('❤')
308+
julia> isuppercase('❤')
309309
false
310310
```
311311
"""
312-
function isupper(c::AbstractChar)
312+
function isuppercase(c::AbstractChar)
313313
cat = category_code(c)
314314
cat == UTF8PROC_CATEGORY_LU || cat == UTF8PROC_CATEGORY_LT
315315
end
@@ -533,7 +533,7 @@ converted to lowercase, otherwise they are left unchanged.
533533
By default, all non-letters are considered as word separators;
534534
a predicate can be passed as the `wordsep` keyword to determine
535535
which characters should be considered as word separators.
536-
See also [`ucfirst`](@ref) to capitalize only the first
536+
See also [`uppercasefirst`](@ref) to capitalize only the first
537537
character in `s`.
538538
539539
# Examples
@@ -564,22 +564,22 @@ function titlecase(s::AbstractString; wordsep::Function = !iscased, strict::Bool
564564
end
565565

566566
"""
567-
ucfirst(s::AbstractString) -> String
567+
uppercasefirst(s::AbstractString) -> String
568568
569569
Return `s` with the first character converted to uppercase (technically "title
570570
case" for Unicode). See also [`titlecase`](@ref) to capitalize the first
571571
character of every word in `s`.
572572
573-
See also: [`lcfirst`](@ref), [`uppercase`](@ref), [`lowercase`](@ref),
573+
See also: [`lowercasefirst`](@ref), [`uppercase`](@ref), [`lowercase`](@ref),
574574
[`titlecase`](@ref)
575575
576576
# Examples
577577
```jldoctest
578-
julia> ucfirst("python")
578+
julia> uppercasefirst("python")
579579
"Python"
580580
```
581581
"""
582-
function ucfirst(s::AbstractString)
582+
function uppercasefirst(s::AbstractString)
583583
isempty(s) && return ""
584584
c = s[1]
585585
c′ = titlecase(c)
@@ -588,20 +588,20 @@ function ucfirst(s::AbstractString)
588588
end
589589

590590
"""
591-
lcfirst(s::AbstractString)
591+
lowercasefirst(s::AbstractString)
592592
593593
Return `s` with the first character converted to lowercase.
594594
595-
See also: [`ucfirst`](@ref), [`uppercase`](@ref), [`lowercase`](@ref),
595+
See also: [`uppercasefirst`](@ref), [`uppercase`](@ref), [`lowercase`](@ref),
596596
[`titlecase`](@ref)
597597
598598
# Examples
599599
```jldoctest
600-
julia> lcfirst("Julia")
600+
julia> lowercasefirst("Julia")
601601
"julia"
602602
```
603603
"""
604-
function lcfirst(s::AbstractString)
604+
function lowercasefirst(s::AbstractString)
605605
isempty(s) && return ""
606606
c = s[1]
607607
c′ = lowercase(c)

doc/src/base/strings.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ Base.last(::AbstractString, ::Integer)
5353
Base.uppercase
5454
Base.lowercase
5555
Base.titlecase
56-
Base.ucfirst
57-
Base.lcfirst
56+
Base.uppercasefirst
57+
Base.lowercasefirst
5858
Base.join
5959
Base.chop
6060
Base.chomp
@@ -66,12 +66,12 @@ Base.isalpha
6666
Base.isascii
6767
Base.iscntrl
6868
Base.isdigit
69-
Base.islower
69+
Base.islowercase
7070
Base.isnumeric
7171
Base.isprint
7272
Base.ispunct
7373
Base.isspace
74-
Base.isupper
74+
Base.isuppercase
7575
Base.isxdigit
7676
Core.Symbol
7777
Base.escape_string

stdlib/Markdown/src/Common/block.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ function admonition(stream::IO, block::MD)
214214
if contains(line, untitled)
215215
m = match(untitled, line)
216216
# When no title is provided we use CATEGORY_NAME, capitalising it.
217-
m.captures[1], ucfirst(m.captures[1])
217+
m.captures[1], uppercasefirst(m.captures[1])
218218
elseif contains(line, titled)
219219
m = match(titled, line)
220220
# To have a blank TITLE provide an explicit empty string as TITLE.

stdlib/Markdown/src/render/plain.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ end
7272

7373
function plain(io::IO, md::Admonition)
7474
s = sprint(plain, md.content)
75-
title = md.title == ucfirst(md.category) ? "" : " \"$(md.title)\""
75+
title = md.title == uppercasefirst(md.category) ? "" : " \"$(md.title)\""
7676
println(io, "!!! ", md.category, title)
7777
for line in split(rstrip(s), "\n")
7878
println(io, isempty(line) ? "" : " ", line)

stdlib/Markdown/src/render/rst.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ end
7676

7777
function rst(io::IO, md::Admonition)
7878
s = sprint(rst, md.content)
79-
title = md.title == ucfirst(md.category) ? "" : md.title
79+
title = md.title == uppercasefirst(md.category) ? "" : md.title
8080
println(io, ".. ", md.category, "::", isempty(title) ? "" : " $title")
8181
for line in split(rstrip(s), "\n")
8282
println(io, isempty(line) ? "" : " ", line)

stdlib/REPL/src/LineEdit.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1028,7 +1028,7 @@ function edit_lower_case(s)
10281028
end
10291029
function edit_title_case(s)
10301030
set_action!(s, :edit_title_case)
1031-
edit_replace_word_right(s, ucfirst)
1031+
edit_replace_word_right(s, uppercasefirst)
10321032
end
10331033

10341034
function edit_replace_word_right(s, replace::Function)

stdlib/Unicode/test/runtests.jl

+28-28
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ end
9393
alower=['a', 'd', 'j', 'y', 'z']
9494
ulower=['α', 'β', 'γ', 'δ', 'ф', 'я']
9595
for c in vcat(alower,ulower)
96-
@test islower(c) == true
97-
@test isupper(c) == false
96+
@test islowercase(c) == true
97+
@test isuppercase(c) == false
9898
@test isdigit(c) == false
9999
@test isnumeric(c) == false
100100
end
@@ -103,8 +103,8 @@ end
103103
uupper= ['Δ', 'Γ', 'Π', 'Ψ', 'Dž', 'Ж', 'Д']
104104

105105
for c in vcat(aupper,uupper)
106-
@test islower(c) == false
107-
@test isupper(c) == true
106+
@test islowercase(c) == false
107+
@test isuppercase(c) == true
108108
@test isdigit(c) == false
109109
@test isnumeric(c) == false
110110
end
@@ -201,8 +201,8 @@ end
201201
@test !all(isspace,"ΣβΣβ")
202202
@test all(isalpha,"ΣβΣβ")
203203
@test all(isprint,"ΣβΣβ")
204-
@test !all(isupper,"ΣβΣβ")
205-
@test !all(islower,"ΣβΣβ")
204+
@test !all(isuppercase,"ΣβΣβ")
205+
@test !all(islowercase,"ΣβΣβ")
206206
@test !all(isnumeric,"ΣβΣβ")
207207
@test !all(iscntrl,"ΣβΣβ")
208208
@test !all(ispunct,"ΣβΣβ")
@@ -329,17 +329,17 @@ end
329329
@test collect(g) == ["1","2","3","α","5"]
330330
end
331331

332-
@testset "ucfirst/lcfirst" begin
333-
@test ucfirst("Hola")=="Hola"
334-
@test ucfirst("hola")=="Hola"
335-
@test ucfirst("")==""
336-
@test ucfirst("*")=="*"
337-
@test ucfirst("DŽxx") == ucfirst("džxx") == "Džxx"
338-
339-
@test lcfirst("Hola")=="hola"
340-
@test lcfirst("hola")=="hola"
341-
@test lcfirst("")==""
342-
@test lcfirst("*")=="*"
332+
@testset "uppercasefirst/lowercasefirst" begin
333+
@test uppercasefirst("Hola")=="Hola"
334+
@test uppercasefirst("hola")=="Hola"
335+
@test uppercasefirst("")==""
336+
@test uppercasefirst("*")=="*"
337+
@test uppercasefirst("DŽxx") == uppercasefirst("džxx") == "Džxx"
338+
339+
@test lowercasefirst("Hola")=="hola"
340+
@test lowercasefirst("hola")=="hola"
341+
@test lowercasefirst("")==""
342+
@test lowercasefirst("*")=="*"
343343
end
344344

345345
@testset "issue #11482" begin
@@ -355,17 +355,17 @@ end
355355
@test lowercase('\U118bf') == '\U118df'
356356
@test uppercase('\U1044d') == '\U10425'
357357
end
358-
@testset "ucfirst/lcfirst" begin
359-
@test ucfirst("Abc") == "Abc"
360-
@test ucfirst("abc") == "Abc"
361-
@test lcfirst("ABC") == "aBC"
362-
@test lcfirst("aBC") == "aBC"
363-
@test ucfirst(GenericString("")) == ""
364-
@test lcfirst(GenericString("")) == ""
365-
@test ucfirst(GenericString("a")) == "A"
366-
@test lcfirst(GenericString("A")) == "a"
367-
@test lcfirst(GenericString("a")) == "a"
368-
@test ucfirst(GenericString("A")) == "A"
358+
@testset "uppercasefirst/lowercasefirst" begin
359+
@test uppercasefirst("Abc") == "Abc"
360+
@test uppercasefirst("abc") == "Abc"
361+
@test lowercasefirst("ABC") == "aBC"
362+
@test lowercasefirst("aBC") == "aBC"
363+
@test uppercasefirst(GenericString("")) == ""
364+
@test lowercasefirst(GenericString("")) == ""
365+
@test uppercasefirst(GenericString("a")) == "A"
366+
@test lowercasefirst(GenericString("A")) == "a"
367+
@test lowercasefirst(GenericString("a")) == "a"
368+
@test uppercasefirst(GenericString("A")) == "A"
369369
end
370370
@testset "titlecase" begin
371371
@test titlecase('lj') == 'Lj'

test/operators.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ Base.promote_rule(::Type{T19714}, ::Type{Int}) = T19714
105105
end
106106
@testset "function negation" begin
107107
str = randstring(20)
108-
@test filter(!isupper, str) == replace(str, r"[A-Z]" => "")
109-
@test filter(!islower, str) == replace(str, r"[a-z]" => "")
108+
@test filter(!isuppercase, str) == replace(str, r"[A-Z]" => "")
109+
@test filter(!islowercase, str) == replace(str, r"[a-z]" => "")
110110
end
111111

112112
# issue #19891

0 commit comments

Comments
 (0)