1--TEST-- 2mb_substr() 3--SKIPIF-- 4<?php extension_loaded('mbstring') or die('skip mbstring not available'); ?> 5--INI-- 6output_handler= 7--FILE-- 8<?php 9// TODO: Add more encodings 10ini_set('include_path','.'); 11include_once('common.inc'); 12 13// EUC-JP 14$euc_jp = '0123����ʸ��������ܸ�Ǥ���EUC-JP��ȤäƤ��ޤ������ܸ�����ݽ�����'; 15 16print "1: ". bin2hex(mb_substr($euc_jp, 10, 10,'EUC-JP')) . "\n"; 17print "2: ". bin2hex(mb_substr($euc_jp, 0, 100,'EUC-JP')) . "\n"; 18 19$str = mb_substr($euc_jp, 100, 10,'EUC-JP'); 20// Note: returns last character 21($str === "") ? print "3 OK\n" : print "NG: ".bin2hex($str)."\n"; 22 23$str = mb_substr($euc_jp, -100, 10,'EUC-JP'); 24($str !== "") ? print "4 OK: ".bin2hex($str)."\n" : print "NG: ".bin2hex($str)."\n"; 25 26?> 27--EXPECT-- 281: c6fccbdcb8eca4c7a4b9a1a34555432d 292: 30313233a4b3a4cecab8bbfacef3a4cfc6fccbdcb8eca4c7a4b9a1a34555432d4a50a4f2bbc8a4c3a4c6a4a4a4dea4b9a1a3c6fccbdcb8eca4cfccccc5ddbdada4a4a1a3 303 OK 314 OK: 30313233a4b3a4cecab8bbfacef3a4cf 32