<?php
require_once(dirname(__FILE__).'/unicode.class.php'); header('Content-type: text/html; charset=UTF-8');
$big_endian = true;
// Original Text $text = 'Simple text with 滝 japanese character';
// UTF-8 to UTF-16 and UTF-16 to UTF-8 $text_utf16 = unicode::utf8_to_utf16($text, $big_endian); $text_utf8 = unicode::utf16_to_utf8($text_utf16, $big_endian); if ($text !== $text_utf8) { echo 'Error while converting between UTF-8 and UTF-16'; exit(1); }
// UTF-8 to UTF-32 and UTF-32 to UTF-8 $text_utf32 = unicode::utf8_to_utf32($text, $big_endian); $text_utf8 = unicode::utf32_to_utf8($text_utf32, $big_endian); if ($text !== $text_utf8) { echo 'Error while converting between UTF-8 and UTF-32'; exit(1); }
// UTF-16 to UTF-32 and UTF-32 to UTF-16 $text = $text_utf16; $text_utf32 = unicode::utf16_to_utf32($text, $big_endian, $big_endian); $text_utf16 = unicode::utf32_to_utf16($text_utf32, $big_endian, $big_endian); if ($text !== $text_utf16) { echo 'Error while converting between UTF-16 and UTF-32'; exit(1); }
echo 'OK'; exit(0);
|