Skip to content

Commit d3698a8

Browse files
authored
add doc string for uppercase(::AbstractChar) and friends (#44351)
1 parent 7cde4be commit d3698a8

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

base/strings/unicode.jl

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,10 +270,64 @@ julia> textwidth("March")
270270
"""
271271
textwidth(s::AbstractString) = mapreduce(textwidth, +, s; init=0)
272272

273+
"""
274+
lowercase(c::AbstractChar)
275+
276+
Convert `c` to lowercase.
277+
278+
See also [`uppercase`](@ref), [`titlecase`](@ref).
279+
280+
# Examples
281+
```jldoctest
282+
julia> lowercase('A')
283+
'a': ASCII/Unicode U+0061 (category Ll: Letter, lowercase)
284+
285+
julia> lowercase('Ö')
286+
'ö': Unicode U+00F6 (category Ll: Letter, lowercase)
287+
```
288+
"""
273289
lowercase(c::T) where {T<:AbstractChar} = isascii(c) ? ('A' <= c <= 'Z' ? c + 0x20 : c) :
274290
T(ccall(:utf8proc_tolower, UInt32, (UInt32,), c))
291+
292+
"""
293+
uppercase(c::AbstractChar)
294+
295+
Convert `c` to uppercase.
296+
297+
See also [`lowercase`](@ref), [`titlecase`](@ref).
298+
299+
# Examples
300+
```jldoctest
301+
julia> uppercase('a')
302+
'A': ASCII/Unicode U+0041 (category Lu: Letter, uppercase)
303+
304+
julia> uppercase('ê')
305+
'Ê': Unicode U+00CA (category Lu: Letter, uppercase)
306+
```
307+
"""
275308
uppercase(c::T) where {T<:AbstractChar} = isascii(c) ? ('a' <= c <= 'z' ? c - 0x20 : c) :
276309
T(ccall(:utf8proc_toupper, UInt32, (UInt32,), c))
310+
311+
"""
312+
titlecase(c::AbstractChar)
313+
314+
Convert `c` to titlecase. This may differ from uppercase for digraphs,
315+
compare the example below.
316+
317+
See also [`uppercase`](@ref), [`lowercase`](@ref).
318+
319+
# Examples
320+
```jldoctest
321+
julia> titlecase('a')
322+
'A': ASCII/Unicode U+0041 (category Lu: Letter, uppercase)
323+
324+
julia> titlecase('dž')
325+
'Dž': Unicode U+01C5 (category Lt: Letter, titlecase)
326+
327+
julia> uppercase('dž')
328+
'DŽ': Unicode U+01C4 (category Lu: Letter, uppercase)
329+
```
330+
"""
277331
titlecase(c::T) where {T<:AbstractChar} = isascii(c) ? ('a' <= c <= 'z' ? c - 0x20 : c) :
278332
T(ccall(:utf8proc_totitle, UInt32, (UInt32,), c))
279333

0 commit comments

Comments
 (0)