Warning: Undefined array key "action" in /home/bakers/html/entryreply.php on line 5

Warning: Undefined variable $output in /home/bakers/html/entryreply.php on line 50

Warning: Undefined array key "EntrySubject" in /home/bakers/html/entryreply.php on line 51

Warning: Undefined variable $logintext in /home/bakers/html/entryreply.php on line 97

Warning: Undefined variable $reply_name in /home/bakers/html/entryreply.php on line 103

Warning: Undefined variable $reply_email in /home/bakers/html/entryreply.php on line 104
Perturb.org - interesting technology related things from around the internet

Unicode code points

I needed to get a raw unicode code point in a couple languages.

# Bash

echo -e "\u2591\u2592\u2593"

You have to tell Perl that STDOUT is utf8, otherwise it will complain about "Wide character".

# Perl

binmode(STDOUT, ":utf8"); 
print "\x{2591}\x{2592}\x{2593}\n";

Here is a small PHP function to make utf-8 chars in PHP

# PHP

function utf8($num) {
    if($num<=0x7F)       return chr($num);
    if($num<=0x7FF)      return chr(($num>>6)+192).chr(($num&63)+128);
    if($num<=0xFFFF)     return chr(($num>>12)+224).chr((($num>>6)&63)+128).chr(($num&63)+128);
    if($num<=0x1FFFFF)   return chr(($num>>18)+240).chr((($num>>12)&63)+128).chr((($num>>6)&63)+128).chr(($num&63)+128);
    return '';
}

print utf8(0x2591) . utf8(0x2592) . utf8(0x2593) . "\n";


Note: Replies will be formatted with PHP Markdown Extra syntax.

Name: Email (Not Required):
 
Logged IP: 3.239.50.33
To prevent spam please submit by clicking the kitten: