Ivan Sagalaev wrote:
> gabor wrote:
> 
>> for example, i was building a very simple web-file-manager. you can ask 
>> python to get you the os.listdir, etc, data in unicode, which i think 
>> the only sensible way, because otherwise you have to watch out for the 
>> filesystem-encoding. but because the querystring and httpresponse is 
>> bytestring, i have .encode('utf8'), .decode('utf8') all the way.
>>  
>>
> Not at all. You can talk to file system in utf-8 and do no conversions 
> at all. I'm doing it in my app and it works just fine.
> 
> I don't know exactly how Python handles encoding of data that it 
> receives from the OS and I think there can be problems with 
> misconfigured OS giving out those characters in a non-UTF8 byte 
> encoding. But unicode here won't help either since Python would try to 
> convert some arbitrary stream to unicode and will throw an exception. 
> With  byte string I suppose you will get the string without errors but 
> with the garbage in it. All this anyway just requires configuring 
> locales properly.


hmm.. i somehow thought that python does this correctly (means: detect 
locale, do the charset stuff)...are you sure that it's not handling it 
correctly?

and what about non-utf8 filesystems (like windows, or some old linux 
that's maybe still in latin1)?
> 
> And as a sidenote: HttpResponse can happily accept unicode with 
> convertion to DEFAULT_CHARSET on actual output.
> 

good to know

 > For example I can very quickly distinguish string that is in
> utf-8 shown in windows-1251 locale from string in windows-1251 shown in 
> utf-8 locale by just looking at it. 

hmm.. i'm not sure that this is a good thing or a bad thing :-))

gabor

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers
-~----------~----~----~----~------~----~------~--~---

Reply via email to