Re: How should PEAR packages support multiple character sets?

From: Date: Wed, 26 Mar 2008 10:58:26 +0000
Subject: Re: How should PEAR packages support multiple character sets?
References: 1 2 3  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-49555@lists.php.net to get a copy of this message
Zitat von Christian Schmidt <lists@chsc.dk>:
Jan Schneider wrote:
I don't. It really depends on the package. For some packages it simply makes sense to assume utf-8 encoding, especially packages dealing with dom and xml, but probably also others.
In your opinion, what kind of package that deals with non-US-ASCII characters should use a character set other than UTF-8?
Any package that can safely deal with arbitrary charsets. Since I happen to be the maintainer, take Console_Table for example. It works fine with any charset supported by the mbstring extension, and I don't see a reason why I should limit users to one or two charsets only.
This has to be documented of course.
I agree. Asssumptions like this should be documented properly. Perhaps it should even be a requirement that the expected encoding is mentioned in all @param and @return tags that refer to strings. This would also make the information available in the tooltip in IDEs.
This may be a bit overzealous, but the direction is correct.
But it doesn't make sense to force passing a charset to those package that work in a certain context where utf-8 is basically the standard.
I disagree. If your code generally assumes that strings are ISO-8859-1, it would be convenient if the DOM extension would all all strings to be ISO-8859-1 rather than UTF-8. Also, I think it is rather subjective which character sets are considered standard in a given context.
It really depends on the package. Take all the Service_* packages for example that provide interfaces to public APIs. Those usually expect data in a fixed charset. Thus it doesn't make sense for those package to accept data in any charset different to that.
Thus, the charset should be passed directly to packages, object ctors, or even methods where it fits best for each package.
If we choose that approach, I suggest that we agree on a uniform way of specifying the character set in constructors etc.
That would help users a lot, though I wonder if there really is much to agree about. You could either use a $charset parameter to constructor and class methods. Or you use a setCharset() method. Jan. Jan. -- Do you need professional PHP or Horde consulting? http://horde.org/consulting/

« previous php.pear.dev (#49555) next »