Given a Unicode decimal or hex number for a character that's wanting to be output from a CLI PHP script, how can PHP generate it? The chr()
function seems to not generate the proper output. Here's my test script, using the Section Break character U+00A7 (A7 in hex, 167 in decimal, should be represented as C2 A7 in UTF-8) as a test:
<?php
echo "Section sign: ".chr(167)."\n"; // Using CHR function
echo "Section sign: ".chr(0xA7)."\n";
echo "Section sign: ".pack("c", 0xA7)."\n"; // Using pack function?
echo "Section sign: §\n"; // Copy and paste of the symbol into source code
The output I get (via a SSH session to the server) is:
Section sign: ?
Section sign: ?
Section sign: ?
Section sign: §
So, that proves that the terminal font I'm using has the Section Break character in it, and the SSH connection is sending it along successfully, but chr()
isn't constructing it properly when constructing it from the code number.
If all I've got is the code number and not a copy/paste option, what options do I have?