Format Accented Characters for URL?

Dave Cragg dave.cragg at lacscentre.co.uk
Tue Sep 25 19:26:13 EDT 2012


On 25 Sep 2012, at 21:29, Scott Rossi <scott at tactilemedia.com> wrote:

> Hi List:
> 
> Wondering if someone has a suggestion for URL character formatting in LCŠ
> 
> I'm trying to format a URL string to submit to Google Maps.  The string is a
> street address that needs to be delimited using "+".  The complication
> arises when an address contains an accented character like ñ (n + tilde).
> If I change the ñ to a roman n, the address is processed, but I thought I
> could use something like urlEncode to handle problem characters.

Hi Scott

I think the + char is an encoded space. That's what LC outputs instead of the %20 alternative.

I'm guessing that strings with characaters such as ñ (n + tilde) need to be in UTF8 format before using url encode.

Example:

Here's a slightly exotic version of a well-known address:

25a Thistlé Street SW Lañe, Edinburgh

If we put that into field 1, then run the following:

put uniDecode(uniEncode(field 1), "UTF8") into tA
put urlencode(tA)

it gives: 25a+Thistl%C3%A9+Street+SW+La%C3%B1e%2C+Edinburgh

If we try this url in a browser:

maps.google.com/maps?q=25a+Thistl%C3%A9+Street+SW+La%C3%B1e%2C+Edinburgh

Apologies if any of the above gets rearranged in the mail.

Dave



More information about the use-livecode mailing list