Actions
Feature #2061
closedNamed Unicode Character Escapes
Description
=begin
I suggest the addition of a \N{name} escape where name is the name of a Unicode character. It would resolve to the corresponding codepoint. 'N' is chosen because it's used by both Perl and Python for the same purpose.
This promotes more readable code compared to \u{} escapes because \N{WHITE SMILING FACE} is self-documenting whereas \u263A isn't. It can even be useful when the source encoding is UTF-8 because the meaning of unfamiliar glyphs is often clearer when they are named.
They should:
- Normalise the name by converting to uppercase and replacing underscores with spaces.
- Force the string's encoding to UTF-8 in the same fashion as \u{}.
- Optionally support Perl's aliases for names containing parentheses as detailed in http://perldoc.perl.org/charnames.html .
- Work inside regexp literals.
I'd hoped to write this patch myself, but was unable. I'm happy to update tool/enc-unicode.rb and RubySpec, if that would help.
=end
Actions
Like0
Like0Like0Like0Like0Like0