Skip to content

Commit fef96e4

Browse files
committed
News and compat annotation for #29153 (ncodeunits(::Char)).
1 parent b5dd9c0 commit fef96e4

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

NEWS.md

+1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ Standard library changes
7373
* `Base.@kwdef` can now be used for parametric structs, and for structs with supertypes ([#29316]).
7474
* `merge(::NamedTuple, ::NamedTuple...)` can now be used with more than 2 `NamedTuple`s ([#29259]).
7575
* `Future.copy!` has been moved to `Base` ([#29178]).
76+
* New `ncodeunits(c::Char)` method as a fast equivalent to `ncodeunits(string(c))` ([#29153]).
7677

7778
Compiler/Runtime improvements
7879
-----------------------------

base/char.jl

+4
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ Char
5656
Return the number of code units required to encode a character as UTF-8.
5757
This is the number of bytes which will be printed if the character is written
5858
to an output stream, or `ncodeunits(string(c))` but computed efficiently.
59+
60+
!!! compat "Julia 1.1"
61+
This method requires at least Julia 1.1. In Julia 1.0 consider
62+
using `ncodeunits(string(c))`.
5963
"""
6064
ncodeunits(c::Char) = write(devnull, c) # this is surprisingly efficient
6165

0 commit comments

Comments
 (0)