On 21 Feb 2013, at 12:08 PM, puercoespin <jzaragoza.puercoes...@gmail.com> 
wrote:
> I have a table with a field with non-ASCII names. And i want to use those to 
> construct the url.
> 
> So, ie,  a Spanish locality as "Aigües Tortes d'alt Ampurdà", I want to send 
> the url: "http://mydomain/init/controller/function/<Aigües Tortes d'alt 
> Ampurdà>'. 
> 
> In the view, in  request.args(0), I want to recover the original name, that 
> is "Aigües...."
> 
> In my solution, first I created a dict to replaced every no-Ascii char of the 
> string {"ü":"u","à":"a", ...........}, and to send the modificated name with 
> the url, and with another dict {"Aigües Tortes d'alt 
> Ampurdà":"Aigues_Tortes_dalt_Ampurda", ...........} recover the original name.
> 
> But later, I read about idna (Internationalized Domain Names in 
> Applications), and in this group , i  read in this group that Jonathan Benn 
> seems to implemet it in IS_URL.
> 
> So my question is: How can i do that, (construct an URL with non-ASCII chars) 
> in web2py?
> 

Notice that i18n of domain names is a different matter from supporting Unicode 
args in your URLs (which I think is what you're after).

I believe that the parametric router will let you use Unicode in your args, if 
you relax args_match appropriately. However, I see that there are no unit tests 
for it, and it occurs to me that it may need to do explicit UTF-8 encoding of 
Unicode args, so it may still need a little work, or you may need to do the 
encoding yourself. The resulting string will eventually be percent-encoded as 
well, but URL will handle that for you (I think).

Speaking of UTF-8, a side note: it's not really meaningful to talk about a URL 
with "non-ASCII characters"; always specify an encoding.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to