Location: PHPKode > scripts > Unicode Manipulation > unicode-manipulation/test_equal.php
<?php

require_once(dirname(__FILE__).'/unicode.class.php');
header('Content-type: text/html; charset=UTF-8');

// big-endian
$b = true;

$x = 0;
for ($ord = 0; $ord < 0x10000; $ord++) {
    $c8  = unicode::chr_utf8($ord);
    $c16 = unicode::chr_utf16($ord, $b);
    $c32 = unicode::chr_utf32($ord, $b);
    
    $o8  = unicode::ord_utf8($c8);
    $o16 = unicode::ord_utf16($c16, $b);
    $o32 = unicode::ord_utf32($c32, $b);

    // Invalid charcode
    if ($o16 === false) {
        continue;
    }

    if ($o8 !== $o16 || $o8 !== $o32) {
        echo 'Error in code '.$i.':  '.$o8.' / '.$o16.' / '.$o32;
        exit(1);
    }
}

echo 'OK';
exit(0);
Return current item: Unicode Manipulation