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:

Note that:

chr(206).chr(178) is binary representation of UTF-8 char no. 946
chr(178).chr(3) is binary representation of UTF-16LE char no. 946
chr(3).chr(178) is binary representation of UTF-16BE char no. 946


Previous Comments:
------------------------------------------------------------------------

[2009-01-12 13:45:39] lunter at interia dot pl

There is no way to calculate base64, sha1 from unicode string
(unicode.script_encoding = UTF-8 [or UTF-16LE,UTF-16BE]) starting from
$unicode=chr(946)

because we don't have method to convert mutli-byte character sets to
it's binary representation 

$unicode=chr(946)

When stript encoding UTF-8, chr(946)
base64($unicode) is zrI=
sha1($unicode) is 25b9b2c8a851851c7e0f1cff29a93a6aa6895f34

When stript encoding UTF-16LE, chr(946)
base64($unicode) is sgM=
sha1($unicode) is e84c936ce61a692fcc5a402b3b9b733592ba0b67

When stript encoding UTF-16BE, chr(946)
base64($unicode) is A7I=
sha1($unicode) is 2403f70ce33aeec4e21a519ffebb2864afc89fda

------------------------------------------------------------------------

[2009-01-12 13:39:02] lunter at interia dot pl

USE OLD PHP 5.x

// ---

valids values of UTF-16LE char(946) base64 / sha1

<?
 print('UTF-16LE char(946):<br>');
 print('base64: '.base64_encode(chr(178).chr(3)).'<br>');
 print('sha1: '.sha1(chr(178).chr(3)).'<br>');
?>

// ---

valids values of UTF-16BE char(946) base64 / sha1

<?
 print('UTF-16BE char(946):<br>');
 print('base64: '.base64_encode(chr(3).chr(178)).'<br>');
 print('sha1: '.sha1(chr(3).chr(178)).'<br>');
?>

------------------------------------------------------------------------

[2009-01-12 13:25:01] lunter at interia dot pl

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>');
?>

------------------------------------------------------------------------

[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].

------------------------------------------------------------------------

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

Reply via email to