ID: 47076
User updated by: lunter at interia dot pl
Reported By: lunter at interia dot pl
Status: Open
Bug Type: Unicode Engine related
Operating System: all
PHP Version: 6CVS-2009-01-12 (CVS)
New Comment:
USE OLD PHP 5.x
valids values of UTF-8 char(946) base64 / sha1
<?
print('UTF-8 char(946):<br>');
print('base64: '.base64_encode(chr(206).chr(178)).'<br>');
print('sha1: '.sha1(chr(206).chr(178)).'<br>');
?>
Previous Comments:
------------------------------------------------------------------------
[2009-01-12 12:54:41] lunter at interia dot pl
All examples above in utf-8
Imagine that using utf-16, sha1 and base64 will be not the same.
------------------------------------------------------------------------
[2009-01-12 12:50:23] lunter at interia dot pl
Please imagine that unicode chr(946) in binary have two bytes [11001110
10110010].
------------------------------------------------------------------------
[2009-01-12 12:45:36] lunter at interia dot pl
Example 4:
<?
print('You have to calculate sha1 of unicode chr(946)<br>');
print('regular sha1 of unicode chr(946) (\uceb2) is:
25b9b2c8a851851c7e0f1cff29a93a6aa6895f34'.'<br><br>');
$unicode=chr(946);
print(sha1((binary)$unicode));
print('<br>');
print(sha1(unicode_encode($unicode,'iso-8859-1')));
print('<br>');
// print(sha1(uni2bin($unicode))); //
25b9b2c8a851851c7e0f1cff29a93a6aa6895f34
?>
------------------------------------------------------------------------
[2009-01-12 12:40:48] lunter at interia dot pl
Example 3:
<?
print('You have to calculate base64 of unicode chr(946)<br>');
print('regular base64 of unicode chr(946) (\uceb2) is:
zrI='.'<br><br>');
$unicode=chr(946);
print(base64_encode((binary)$unicode));
print('<br>');
print(base64_encode(unicode_encode($unicode,'iso-8859-1')));
print('<br>');
// print(base64_encode(uni2bin($unicode))); // zrI=
?>
------------------------------------------------------------------------
[2009-01-12 12:25:21] lunter at interia dot pl
Two new functions needed:
(binary) uni2bin( (string) unicode data )
(string) bin2uni( (binary) binary data )
diference beetwen unicode_(en|de)code is: convert WITHOUT using charser
translation
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/47076
--
Edit this bug report at http://bugs.php.net/?id=47076&edit=1