X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2Fcharnames.pm;h=9f9526b9654f5c441afb36b58ea98324572dbfae;hb=ff504b36b0f6467f64b463fd17fb34f640855abc;hp=3b42738eb6e502a09056be9afee0b2cefc9fb294;hpb=075d4edd61a9648945541c8a76d8c03d4588400b;p=p5sagit%2Fp5-mst-13.2.git diff --git a/lib/charnames.pm b/lib/charnames.pm index 3b42738..9f9526b 100644 --- a/lib/charnames.pm +++ b/lib/charnames.pm @@ -384,33 +384,55 @@ U+0084, and U+0099 do not have names even in ISO 6429. Since the Unicode standard uses "U+HHHH", so can you: "\N{U+263a}" is the Unicode smiley face, or "\N{WHITE SMILING FACE}". -=head1 CUSTOM TRANSLATORS +=head1 ALIASES -The mechanism of translation of C<\N{...}> escapes is general and not -hardwired into F. A module can install custom -translations (inside the scope which Cs the module) with the -following magic incantation: +A few aliases have been defined for convenience: instead of having +to use the official names - sub import { - shift; - $^H{charnames} = \&translator; - } + LINE FEED (LF) + FORM FEED (FF) + CARRIAGE RETURN (CR) + NEXT LINE (NEL) -Here translator() is a subroutine which takes C as an -argument, and returns text to insert into the string instead of the -C<\N{CHARNAME}> escape. Since the text to insert should be different -in C mode and out of it, the function should check the current -state of C-flag as in: +(yes, with parentheses) one can use - use bytes (); # for $bytes::hint_bits - sub translator { - if ($^H & $bytes::hint_bits) { - return bytes_translator(@_); - } - else { - return utf8_translator(@_); - } - } + LINE FEED + FORM FEED + CARRIAGE RETURN + NEXT LINE + LF + FF + CR + NEL + +One can also use + + BYTE ORDER MARK + BOM + +and + + ZWNJ + ZWJ + +for ZERO WIDTH NON-JOINER and ZERO WIDTH JOINER. + +For backward compatibility one can use the old names for +certain C0 and C1 controls + + old new + + HORIZONTAL TABULATION CHARACTER TABULATION + VERTICAL TABULATION LINE TABULATION + FILE SEPARATOR INFORMATION SEPARATOR FOUR + GROUP SEPARATOR INFORMATION SEPARATOR THREE + RECORD SEPARATOR INFORMATION SEPARATOR TWO + UNIT SEPARATOR INFORMATION SEPARATOR ONE + PARTIAL LINE DOWN PARTIAL LINE FORWARD + PARTIAL LINE UP PARTIAL LINE BACKWARD + +but the old names in addition to giving the character +will also give a warning about being deprecated. =head1 CUSTOM ALIASES @@ -480,55 +502,33 @@ Returns undef if the name is unknown. This works only for the standard names, and does not yet apply to custom translators. -=head1 ALIASES - -A few aliases have been defined for convenience: instead of having -to use the official names - - LINE FEED (LF) - FORM FEED (FF) - CARRIAGE RETURN (CR) - NEXT LINE (NEL) - -(yes, with parentheses) one can use - - LINE FEED - FORM FEED - CARRIAGE RETURN - NEXT LINE - LF - FF - CR - NEL - -One can also use - - BYTE ORDER MARK - BOM - -and - - ZWNJ - ZWJ - -for ZERO WIDTH NON-JOINER and ZERO WIDTH JOINER. +=head1 CUSTOM TRANSLATORS -For backward compatibility one can use the old names for -certain C0 and C1 controls +The mechanism of translation of C<\N{...}> escapes is general and not +hardwired into F. A module can install custom +translations (inside the scope which Cs the module) with the +following magic incantation: - old new + sub import { + shift; + $^H{charnames} = \&translator; + } - HORIZONTAL TABULATION CHARACTER TABULATION - VERTICAL TABULATION LINE TABULATION - FILE SEPARATOR INFORMATION SEPARATOR FOUR - GROUP SEPARATOR INFORMATION SEPARATOR THREE - RECORD SEPARATOR INFORMATION SEPARATOR TWO - UNIT SEPARATOR INFORMATION SEPARATOR ONE - PARTIAL LINE DOWN PARTIAL LINE FORWARD - PARTIAL LINE UP PARTIAL LINE BACKWARD +Here translator() is a subroutine which takes C as an +argument, and returns text to insert into the string instead of the +C<\N{CHARNAME}> escape. Since the text to insert should be different +in C mode and out of it, the function should check the current +state of C-flag as in: -but the old names in addition to giving the character -will also give a warning about being deprecated. + use bytes (); # for $bytes::hint_bits + sub translator { + if ($^H & $bytes::hint_bits) { + return bytes_translator(@_); + } + else { + return utf8_translator(@_); + } + } =head1 ILLEGAL CHARACTERS