Login   Register  
PHP Classes
elePHPant
Icontem

File: test_size.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Rubens Takiguti Ribeiro  >  Unicode Manipulation  >  test_size.php  >  Download  
File: test_size.php
Role: Unit test script
Content type: text/plain
Description: Test character size
Class: Unicode Manipulation
Manipulate text with Unicode encodings
Author: By
Last change:
Date: 2008-12-16 08:16
Size: 844 bytes
 

Contents

Class file image Download
<?php

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

$big_endian true;

// Text Examples
$array_utf8 = array(chr(10),  // Control
                    
'a',      // ASCII
                    
'Ԋ',      // UTF-8
                    
'滝',     // UTF-8
                   
);

foreach (
$array_utf8 as $i => $text_utf8) {
    
$text_utf16 unicode::utf8_to_utf16($text_utf8$big_endian);
    
$text_utf32 unicode::utf8_to_utf32($text_utf8$big_endian);

    echo 
'<p>Character '.$i.'</p>';
    echo 
'<p>UTF-8: '.unicode::utf8_size($text_utf8).' / '.strlen($text_utf8).'</p>';
    echo 
'<p>UTF-16: '.unicode::utf16_size($text_utf16).' / '.strlen($text_utf16).'</p>';
    echo 
'<p>UTF-32: '.unicode::utf32_size($text_utf32).' / '.strlen($text_utf32).'</p>';
    echo 
'<hr />';
}
exit(
0);