Skip to content

Commit 38da879

Browse files
committed
News and compat annotation for #29153 (ncodeunits(::Char)).
1 parent 8abf282 commit 38da879

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ Standard library changes
6464
* `Base.@kwdef` can now be used for parametric structs, and for structs with supertypes ([#29316]).
6565
* `merge(::NamedTuple, ::NamedTuple...)` can now be used with more than 2 `NamedTuple`s ([#29259]).
6666
* `Future.copy!` has been moved to `Base` ([#29178]).
67+
* New `ncodeunits(c::Char)` method as a fast equivalent to `ncodeunits(string(c))` ([#29153]).
6768

6869
Compiler/Runtime improvements
6970
-----------------------------

base/char.jl

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