Character codes: Difference between revisions

separate Perl 5 and Perl 6 entries
(separate Perl 5 and Perl 6 entries)
Line 690:
writeln(chr(97));</lang>
 
=={{header|Perl}} and {{header|Perl 6}}==
Here character is just a string of length 1
<lang perl>print ord('a'), "\n"; # prints "97"
print chr(97), "\n"; # prints "a"</lang>
=={{header|Perl 6}}==
Both Perl 5 and Perl 6 have good Unicode support. Note that even characters outside the BMP are considered single characters, not a surrogate pair. Here we use the character "four dragons" (with 64 strokes!) to demonstrate that.
<lang perl6>say ord('𪚥').fmt('0x%04x');
say chr(0x2a6a5);</lang>
{{out}}
<pre>0x2a6a5
𪚥</pre>
 
=={{header|PHP}}==
Anonymous user