[Zope-Coders] Re: [Zope-dev] Unicode treatment in 2.6b1

Florent Guillaume fg@nuxeo.com
30 Sep 2002 14:00:28 +0200


On Mon, 2002-09-30 at 08:50, Toby Dickenson wrote:
> > Because if, say, some Greek guy puts 8-bit strings in the source of his
> > pages (and believe me he does it all the time :-), and in the attributes
> > of objects, they're all likely to be in *his* native default encoding,
> > which happens to be latin-7. Until Unicode was in, he just had to slap a
> > content-type: text/html; charset=iso-8859-7 and all was well. Same thing
> > for Russian, Japanese, etc. My point is that it is very likely that
> > there was a uniformity of encodings (otherwise the application would
> > already render weirdly on the browsers).
> 
> Yes. I can see that alot of legacy zope had to work that way. So far I had 
> assumed that this practice would die out once unicode support was available 
> throughout the framework, and books. Any thoughts on this?

I'm pretty sure that 90% of the installed base is still using this
practice. I have no hard numbers though, being in a latin-1 country.

> > Providing an explicit charset for conversions
> > (maybe simply as an environment variable, that's for legacy after all)
> > would correct that.
> 
> An environment variable would be better than per-document settings.
> 
> Suppose this Greek wants to publish a product, but the rest of the world finds 
> that it only works if this environment variable is set to latin-7.  A more 
> likely scenario is that the greek developer will find products only work if 
> the environment variable is unset, or set to latin-1. Is this an overall 
> better solution?

Ok, here's something that occured to me:
Why not explicitely use "locale.getlocale()[1] or 'latin=1'" as the
default encoding for all str->unicode conversions? We wouldn't rely on a
sys.setdefaultencoding that's harder to customize (why can't user code
change the sys default encoding after initialization BTW?).

I think this would solve the configuration problem and fit the current
usage.

Florent



-- 
Florent Guillaume, Nuxeo (Paris, France)
+33 1 40 33 79 87  http://nuxeo.com  mailto:fg@nuxeo.com