Req #70928 [NEW]: base_convert should distinguish capital letter

From: Date: Tue, 17 Nov 2015 09:43:04 +0000
Subject: Req #70928 [NEW]: base_convert should distinguish capital letter
Groups: php.standards 
Request: Send a blank email to standards-+get-883@lists.php.net to get a copy of this message
From: tony at prettysimplegames dot com Operating system: All PHP version: Irrelevant Package: PHP Language Specification Bug Type: Feature/Change Request Bug description:base_convert should distinguish capital letter Description: ------------ --- From manual page: http://www.php.net/function.base-convert --- base_convert function in the documentation is displayed with a capital letter. The fact that base_convert accept to transform a capital letter and convert it to the same letter in lower case is confusing and can cause serious problem. If you base_convert from a base A to a base B, and then convert from base B to base A the original string is not the same. In the ext/standard/math.c file the total base is without capital letters: PHPAPI zend_string * _php_math_longtobase(zval *arg, int base) { static char digits[] = "0123456789abcdefghijklmnopqrstuvwxyz"; Test script: --------------- $original_string = "A1"; $string_in_base_two = base_convert($original_string, 32, 2); $string_in_base_thirty_two = base_convert($string_in_base_two, 2, 32); var_dump($string_in_base_two); var_dump($string_in_base_thirty_two); var_dump($original_string == $string_in_base_thirty_two); Expected result: ---------------- - At least update the documentation and add the dictionary "0123456789abcdefghijklmnopqrstuvwxyz" and remove the example with the capital letter. - At best throw an error/return false when the base_convert function is used with invalid range: base_convert("A1", 32, 2) must return false in my opinion. Actual result: -------------- base_convert("A1", 32, 2) return the same thing as base_convert("a1", 32, 2) -- Edit bug report at https://bugs.php.net/bug.php?id=70928&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=70928&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=70928&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=70928&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=70928&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=70928&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=70928&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=70928&r=needscript Try newer version: https://bugs.php.net/fix.php?id=70928&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=70928&r=support Expected behavior: https://bugs.php.net/fix.php?id=70928&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=70928&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=70928&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=70928&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=70928&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=70928&r=dst IIS Stability: https://bugs.php.net/fix.php?id=70928&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=70928&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=70928&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=70928&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=70928&r=mysqlcfg

« previous php.standards (#883) next »