From:             
Operating system: Ubuntu 10.10
PHP version:      5.4.3
Package:          I18N and L10N related
Bug Type:         Bug
Bug description:Collator::getSortKey returns garbage

Description:
------------
I tried to use the same code snippet as the one given on
Collator::getSortKey's manual page
(http://php.net/manual/en/collator.getsortkey.php).
This resulted in a PHP Warning about a non zero-terminated string and a
different output.

I get the same results (warning + incorrect sort key) on both a 32 bits and
a 64 bits build of PHP 5.2.17 (with intl installed from PECL), 5.3.13 &
5.4.3,

Here's the configure line I used for PHP 5.4.3 (64 bits build with debug
symbols):

'./configure' \
'--disable-all' \
'--disable-short-tags' \
'--disable-sigchild' \
'--enable-debug' \
'--with-layout=GNU' \
'--with-regex' \
'--with-openssl' \
'--with-zlib' \
'--enable-bcmath' \
'--with-bz2' \
'--enable-calendar' \
'--with-gd' \
'--enable-gd-native-ttf' \
'--with-gettext' \
'--with-gmp' \
'--enable-mbstring' \
'--enable-pcntl' \
'--with-readline' \
'--enable-soap' \
'--enable-sockets' \
'--with-pdo-sqlite' \
'--enable-sysvmsg' \
'--enable-sysvsem' \
'--enable-sysvshm' \
'--with-xsl' \
'--with-iconv' \
'--enable-zip' \
'--enable-posix' \
'--enable-libxml' \
'--enable-dom' \
'--enable-xml' \
'--enable-xmlreader' \
'--enable-xmlwriter' \
'--enable-simplexml' \
'--enable-tokenizer' \
'--enable-pdo' \
'--enable-ctype' \
'--enable-json' \
'--enable-session' \
'--enable-intl' \
'--enable-phar' \
'--with-sqlite3' \
'--prefix=/home/.../php-5.4.3-debug' \
'--exec-prefix=/home/.../php-5.4.3-debug' \
'--with-pear=/home/.../php-5.4.3-debug/pear'


Test script:
---------------
<?php

// Same as the one on http://php.net/manual/en/collator.getsortkey.php

$s1 = 'Hello';

$coll = collator_create( 'en_US' );
$res  = collator_get_sort_key( $coll, $s1);

echo urlencode($res);
?>


Expected result:
----------------
71%3F%3FE%01%09%01%8F%08%00 // No warning and same result as in the manual

Actual result:
--------------
PHP 5.2.17:

PHP Warning:  String is not zero-terminated (:4BBH     ) (source:
/home/.../php-5.2.17-debug/Zend/zend_execute_API.c:414) in Command line
code on line 1
PHP Stack trace:
PHP   1. {main}() Command line code:0
%3A4BBH%01%09%01%8F%08%00

-----

PHP 5.3.13:

PHP Warning:  String is not zero-terminated (:4BBH     ) (source:
/home/.../php-5.3.13-debug/Zend/zend_execute_API.c:447) in Command line
code on line 1
PHP Stack trace:
PHP   1. {main}() Command line code:0
%3A4BBH%01%09%01%8F%08%00

-----

PHP 5.4.3:

PHP Warning:  String is not zero-terminated (:4BBH     ) (source:
/home/.../php-5.4.3-debug/Zend/zend_execute.h:87) in Command line code on
line 1
PHP Stack trace:
PHP   1. {main}() Command line code:0
%3A4BBH%01%09%01%8F%08%00

-- 
Edit bug report at https://bugs.php.net/bug.php?id=62070&edit=1
-- 
Try a snapshot (PHP 5.4):            
https://bugs.php.net/fix.php?id=62070&r=trysnapshot54
Try a snapshot (PHP 5.3):            
https://bugs.php.net/fix.php?id=62070&r=trysnapshot53
Try a snapshot (trunk):              
https://bugs.php.net/fix.php?id=62070&r=trysnapshottrunk
Fixed in SVN:                        
https://bugs.php.net/fix.php?id=62070&r=fixed
Fixed in SVN and need be documented: 
https://bugs.php.net/fix.php?id=62070&r=needdocs
Fixed in release:                    
https://bugs.php.net/fix.php?id=62070&r=alreadyfixed
Need backtrace:                      
https://bugs.php.net/fix.php?id=62070&r=needtrace
Need Reproduce Script:               
https://bugs.php.net/fix.php?id=62070&r=needscript
Try newer version:                   
https://bugs.php.net/fix.php?id=62070&r=oldversion
Not developer issue:                 
https://bugs.php.net/fix.php?id=62070&r=support
Expected behavior:                   
https://bugs.php.net/fix.php?id=62070&r=notwrong
Not enough info:                     
https://bugs.php.net/fix.php?id=62070&r=notenoughinfo
Submitted twice:                     
https://bugs.php.net/fix.php?id=62070&r=submittedtwice
register_globals:                    
https://bugs.php.net/fix.php?id=62070&r=globals
PHP 4 support discontinued:          
https://bugs.php.net/fix.php?id=62070&r=php4
Daylight Savings:                    https://bugs.php.net/fix.php?id=62070&r=dst
IIS Stability:                       
https://bugs.php.net/fix.php?id=62070&r=isapi
Install GNU Sed:                     
https://bugs.php.net/fix.php?id=62070&r=gnused
Floating point limitations:          
https://bugs.php.net/fix.php?id=62070&r=float
No Zend Extensions:                  
https://bugs.php.net/fix.php?id=62070&r=nozend
MySQL Configuration Error:           
https://bugs.php.net/fix.php?id=62070&r=mysqlcfg

Reply via email to