Hi Aaron,
Sorry for my weird comment on ticket. 2588 - I should have spent more time discussing what I really meant. I'm not sure why 0x2f would ever be a chinese character. URLs are supposed to be encoded as UTF8 as per RFC 2718 and RFC 3986. Using GB18030 and GB2312, I get this: In [6]: '/'.decode('gb18030') Out[6]: u'/' In [7]: '/'.decode('gb2312') Out[7]: u'/' How are you getting a chinese block character for 0x2f? If you want to handle 'unicode' URLs, you should assume that the URLs are UTF8 and decode the path as such. http://groups.google.com/group/django-users/browse_thread/thread/52349f0968f5b36b/07adcb5763a09a5a In my UTF8 decoding middleware layer, I have a little bit of code that forces the path to be decoded as UTF8, then as latin1 so that i get a transient unicode string. I then re-encode the data back to utf8 (since it might have been latin1). That *should* handle your problem. I haven't specifically tested against chinese, but it does work with "Ă…land Islands". Give it a try and if it doesn't work - I'll see if I can tweak my middleware a bit. vic vic On 12/23/06, Aaron Jacobs <[EMAIL PROTECTED]> wrote:
In the interest of making 'pretty' URLs, I want my application to accept URLs that may potentially contain Chinese characters, and have those URLs parsed by URLconfs. The [Django book] [1] says the following: > When a request comes in, Django tries to match the URLconf patterns against > the requested URL, as a normal Python string (not as a Unicode string). Is there any way to accomplish what I want? On Trac and the mailing list I found some [efforts] [2] by Victor Ng to Unicode-ify things, but nothing seems to ever have been made of them. The last modification to that ticket gives what sounds like a solution, but honestly I can't say that I understand exactly what it says. Any tips? Aaron [1]: http://www.djangobook.com/en/beta/chapter08/ [2]: http://code.djangoproject.com/ticket/2588 >
-- "Never attribute to malice that which can be adequately explained by stupidity." - Hanlon's Razor --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@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-users?hl=en -~----------~----~----~----~------~----~------~--~---