₹
HTML Entity (decimal) ₹
HTML Entity (hex) ₹
How to type in Microsoft Windows Alt +20B9
UTF-8 (hex) 0xE2 0x82 0xB9 (e282b9)
UTF-8 (binary) 11100010:10000010:10111001
UTF-16 (hex) 0x20B9 (20b9)
UTF-16 (decimal) 8,377
UTF-32 (hex) 0x000020B9 (20b9)
UTF-32 (decimal) 8,377
I need to print this char, I'm doing this:
$str = htmlentities('₹');
echo html_entity_decode($str);
but it just outputs ₹
. I'm expecting the char ₹
A character reference like ₹
is not recognized without the trailing semicolon. Moreover, you can simply use
echo "₹"
or (if you are properly using UTF-8 throughout, which is recommendable) simply
echo "₹";
And quite often you don’t need echo
, as you can simply write the reference ₹
or the character ₹
in HTML.
Whether browsers render the “₹” character is a different issue; you should normally do some font settings, possibly with a downloadable font, @font-face
.
Figured it:
echo html_entity_decode('₹', ENT_NOQUOTES, 'UTF-8');
echo "₹";
Works as long as you are outputting to HTML content, where character references apply. No good for other formats (eg injecting into JavaScript).
echo "₹";
Will work fine as long as your source file is saved in UTF-8 encoding.
Otherwise, the UTF-8 byte encoding of character U+20B9 Indian Rupee Sign is 0xE2, 0x82, 0xB9. So:
echo "\xE2\x82\xB9";
Or, using a function to create UTF-8 strings from code point numbers:
function unichr($i) {
return iconv('UCS-4LE', 'UTF-8', pack('V', $i));
}
echo unichr(0x20B9);
User contributions licensed under CC BY-SA 3.0