Text encoding problem

David Bovill david.bovill at gmail.com
Sun Dec 6 11:38:37 EST 2009


Trying to figure out what this means logically (please correct me if I am
wrong). The url as appears in a web browser as:

http://wiki.architex.tv/Güstrow <http://wiki.architex.tv/G%C3%BCstrow>
>

However using the above ascii text to fetch a url, or with revBrowserSet as
follows:

put url "http://wiki.architex.tv/Güstrow<http://wiki.architex.tv/G%C3%BCstrow>
"
revBrowserSet browserID, "url",
"http://wiki.architex.tv/Güstrow<http://wiki.architex.tv/G%C3%BCstrow>
"

does not work (it fetches the wrong url). Instead you need to use:

put url "http://wiki.architex.tv/G%C3%BCstrow"
> revBrowserSet browserID, "url", "http://wiki.architex.tv/G%C3%BCstrow"
>

So it seems that the way browser urls work, is that behind the scenes it
translates the displayed url into utf8 and then urlencodes it. You can
replicate this behavior using a function like the one below:

function text_ToBrowserUrl someText
  -- if the platform is not "MacOS" then put isotomac (someText) into
someText
   put uniencode (someText) into uText
   put unidecode (uText,"utf8") into utf8Text
   put urlencode(utf8Text) into urlText
   return urlText
end text_ToBrowserUrl

NB - you don't need to use the isotomac part - that's only there as I'm
working on the Mac and Björnke I guess is on the PC



More information about the use-livecode mailing list