Eric Brine wrote: > On Wed, Jan 6, 2010 at 2:42 PM, karl williamson <public@khwilliamson.com>wrote: > >> And the documentation fore utf8::encode is unclear. It doesn't say for >> example, what happens if the input string is already in utf8. >> > > It says it encodes the input string, and that's what it does. Are you saying > you want to *add* documentation about the UTF8 flag there? We were just > talking about *eliminating* misleading mentions of the UTF8 flag. > Here's what it currently says utf8::encode($string) Converts in-place the character sequence to the orresponding octet sequence in UTF-X. The UTF8 flag is turned off, so that after this operation, the string is a byte string. Returns nothing. I remember reading that for the first time and remaining clueless about why one would want to do that, and what format $string is allowed to be in. Just above it, for utf8::upgrade, it says that "$string already encoded as characters does no harm." That could be worded better, by saying, for example, "... is a no-op", but at least it addresses the issue. As a naive user, I read the entry for encode(), and contrast it with the one for upgrade(), and think if $string is already in utf8, then this probably does harm, and hence I should make sure $string is not in utf8 before using it. I gather from this thread that this function is used just before outputting a string as a stream of utf8-encoded characters. And perhaps if I had ever had written network interface code in Perl I would divined the usefulness of this immediately. But to a naive user, such as myself, why would you convert to utf8 and then pretend it's not?Thread Previous | Thread Next