PHP Classes

File: test_equal.php

Recommend this page to a friend!
  Classes of Rubens Takiguti Ribeiro   Unicode Manipulation   test_equal.php   Download  
File: test_equal.php
Role: Unit test script
Content type: text/plain
Description: Test equal
Class: Unicode Manipulation
Manipulate text with Unicode encodings
Author: By
Last change:
Date: 15 years ago
Size: 655 bytes
 

Contents

Class file image Download
<?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);