in reply to Re^7: Warning: Unicode bytes!
in thread Warning: Unicode bytes!

Hugo, I'm curious to know if you can think of any reason to use bytes in 5.8.4 and onward?

My understanding is that utf8 is treated like tainted data: if you don't introduce any, it won't rear its ugly head.

Replies are listed 'Best First'.
Re^9: Warning: Unicode bytes!
by tye (Sage) on Apr 26, 2004 at 17:46 UTC

    I don't find it that hard to come up with cases where I'd want to look at the bytes used to represent some UTF-8 string. Probably these could be done by unsetting the UTF-8 bit on the string (or on a copy of it), but there being more than one way is Perlish.

    For example, I might just want to know the storage size of a UTF-8 string. Perhaps I have an algorithm that compresses using the concepts of bytes but I want it to "just work" when given a string, whether it is UTF-8 or not. Perhaps I want to transmit a UTF-8 string over a system that has problems with some specific bytes and I want to check for those bytes. Perhaps I want to uuencode a UTF-8 string. Perhaps I need to compute a byte-based checksum of a UTF-8 string.

    - tye        

Re^9: Warning: Unicode bytes!
by hv (Prior) on Apr 26, 2004 at 15:56 UTC

    I certainly wouldn't rule it out: I can imagine there are times you'd want to peek at the internal encoding of a string. However the only reason I can think of off the top of my head is to investigate a problem that you think may be a bug in perl, and there are other hammers I'd usually grab first in such cases (such as Devel::Peek, perl -Dxxx and the hammer-of-hammers gdb).

    Hugo