Skip to content

Commit d146e23

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 d146e23

File tree

13 files changed

+74
-65
lines changed

13 files changed

+74
-65
lines changed

NEWS.md

Lines changed: 5 additions & 1 deletion
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

Lines changed: 5 additions & 0 deletions
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

Lines changed: 4 additions & 4 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 19 additions & 19 deletions
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

Lines changed: 4 additions & 4 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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)

0 commit comments

Comments
 (0)