File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,27 @@ use mem;
18
18
use ops:: Range ;
19
19
20
20
/// Extension methods for ASCII-subset only operations on string slices.
21
+ ///
22
+ /// Be aware that operations on seemingly non-ASCII characters can sometimes
23
+ /// have unexpected results. Consider this example:
24
+ ///
25
+ /// ```
26
+ /// use std::ascii::AsciiExt;
27
+ ///
28
+ /// assert_eq!("café".to_ascii_uppercase(), "CAFÉ");
29
+ /// assert_eq!("café".to_ascii_uppercase(), "CAFé");
30
+ /// ```
31
+ ///
32
+ /// In the first example, the lowercased string is represented `"cafe\u{301}"`
33
+ /// (the last character is an acute accent [combining character]). Unlike the
34
+ /// other characters in the string, the combining character will not get mapped
35
+ /// to an uppercase variant, resulting in `"CAFE\u{301}"`. In the second
36
+ /// example, the lowercased string is represented `"caf\u{e9}"` (the last
37
+ /// character is a single Unicode character representing an 'e' with an acute
38
+ /// accent). Since the last character is defined outside the scope of ASCII,
39
+ /// it will not get mapped to an uppercase variant, resulting in `"CAF\u{e9}"`.
40
+ ///
41
+ /// [combining character]: https://en.wikipedia.org/wiki/Combining_character
21
42
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
22
43
pub trait AsciiExt {
23
44
/// Container type for copied ASCII characters.
You can’t perform that action at this time.
0 commit comments