Hi, On Sat, 2008-05-24 at 13:55 +0100, "Steph Fox" wrote: > Warning: crc32() expects parameter 1 to be strictly a binary string, Unicode > string given in ... > > Surely if a function's *expecting* a binary string it should do a silent > conversion, and only throw a warning if the conversion fails? I don't see > why the onus should always be on the user to adapt to this.
For some functions taking binary strings is critical for working nicely with an automatic conversion in this case crc32(u"äöü") and crc32(b"äöü") would give completely different results depending on the runtime encoding, relying on a implicit conversion there is most likely a bug (at least for apps written with PHP 6 in mind). Oh and I might probably also argue that crc32(u"äöü") should give the crc32 of the internal representation (utf-16...) of the string, which is a total wtf for the user then. The correct solution is to make safe use of the "S" modifier and not using it too much. As binary casts are allowed in modern PHP versions I don't see this as an issue, while such a cast isn't absolutely the best thing to do: I'd go with unicode_encode() to be sure about the encoding being used, everything else is prone to fail some time (some code changing unicode.runtime_encoding for some random reason...) johannes -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php