build url web for a file name with accented letter
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- VIP Livecode Opensource Backer
- Posts: 2718
- Joined: Sat Dec 22, 2007 5:35 pm
- Location: Genève
- Contact:
build url web for a file name with accented letter
Hi All
I look for build a valid url for a file name with accented letters
On a server there is a file called "boîte.png", I noticed the http name is "bo%C3%AEte.png" and it works with this name
I thought I could use urlencode to get the same but
urlEncode(boîte) = "bo%94te"
How can I translate "boîte.png" to "bo%C3%AEte.png" ?
Thanks again for your lights
Jean-Marc
I look for build a valid url for a file name with accented letters
On a server there is a file called "boîte.png", I noticed the http name is "bo%C3%AEte.png" and it works with this name
I thought I could use urlencode to get the same but
urlEncode(boîte) = "bo%94te"
How can I translate "boîte.png" to "bo%C3%AEte.png" ?
Thanks again for your lights
Jean-Marc
Last edited by jmburnod on Tue Jul 03, 2018 6:26 pm, edited 3 times in total.
https://alternatic.ch
Re: how build url web for a file name with accented letter ?
Replace î with %C3% or the reverse? I`m guessing this char is allways represented like that.
Just a thought
Code: Select all
Put "http:\\blablabla\blabla\boîte.jpg" into tUrl
Replace "î" with "%C3%" in tUrl
Knowledge is meant to be shared.
-
- VIP Livecode Opensource Backer
- Posts: 2718
- Joined: Sat Dec 22, 2007 5:35 pm
- Location: Genève
- Contact:
Re: how build url web for a file name with accented letter ?
Hi Zaxos
Thanks for reply
With your script I get "bo%C3%te.jpg" instead "bo%C3%AEte.jpg"
Best regards
Jean-Marc
Thanks for reply
Unfortunately notReplace î with %C3% or the reverse?
With your script I get "bo%C3%te.jpg" instead "bo%C3%AEte.jpg"
Best regards
Jean-Marc
https://alternatic.ch
Re: how build url web for a file name with accented letter ?
then just
replace "î" with "%C3%AE" in tUrl
but it might be worthwhile trying to find our why the filename has been encoded like that. It looks like a problem interpreting between UTF-8 and ISO-8859-1 or Windows-1252 code sets. If you can find out the encoding used, you might be able to make it match from LiveCode by using the matching code set, rather than hard coding a replacement. But that might get pretty complicated.
replace "î" with "%C3%AE" in tUrl
but it might be worthwhile trying to find our why the filename has been encoded like that. It looks like a problem interpreting between UTF-8 and ISO-8859-1 or Windows-1252 code sets. If you can find out the encoding used, you might be able to make it match from LiveCode by using the matching code set, rather than hard coding a replacement. But that might get pretty complicated.
-
- VIP Livecode Opensource Backer
- Posts: 7228
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: how build url web for a file name with accented letter ?
If you are using LC 7.x you can use the built-in unicode support to translate:
In LC 7, all text exported or imported from/to LiveCode should be textEncoded or textDecoded so it is compatible with external apps and servers that have unicode support. Text encoding will not alter non-unicode characters, so it is safe to use on all text.
If you are using LC 6.x then you'll need to use the more awkward uniEncode/uniDecode functions which are now deprecated.
Code: Select all
get "boîte" -- or any other text
put urlEncode(textEncode(it,"utf8"))
If you are using LC 6.x then you'll need to use the more awkward uniEncode/uniDecode functions which are now deprecated.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: how build url web for a file name with accented letter ?
Ah great, now I can test I see that is the unicode representation in UTF-8. I was unsure if the file name had been encoded with a different (eg Windows-1252) encoding. This works nicely though. Here's your solution Jean-Marc.
-
- VIP Livecode Opensource Backer
- Posts: 2718
- Joined: Sat Dec 22, 2007 5:35 pm
- Location: Genève
- Contact:
Re: how build url web for a file name with accented letter ?
Thanks at all,
It works fine with LC 7.
Jaque said there is a way for LC 6.7 but I'm not yet able to use it
Is there an example of "uniEncode/uniDecode" way for 6.7 ?
Jean-Marc
It works fine with LC 7.
Jaque said there is a way for LC 6.7 but I'm not yet able to use it
Is there an example of "uniEncode/uniDecode" way for 6.7 ?
Jean-Marc
https://alternatic.ch
-
- VIP Livecode Opensource Backer
- Posts: 2718
- Joined: Sat Dec 22, 2007 5:35 pm
- Location: Genève
- Contact:
Re: how build url web for a file name with accented letter ?
I found a quick but dirty way to translate an accented file name.
We can create a list of translated accented chars in LC 7 using unicode.
This list can be used in LC 6.7 with a search/replace
We can create a list of translated accented chars in LC 7 using unicode.
This list can be used in LC 6.7 with a search/replace
https://alternatic.ch
-
- VIP Livecode Opensource Backer
- Posts: 7228
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: how build url web for a file name with accented letter ?
You can use the older method this way:
Code: Select all
get "boîte"
put urlEncode(unidecode(uniencode(it), "UTF8")) into tURL
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
-
- VIP Livecode Opensource Backer
- Posts: 2718
- Joined: Sat Dec 22, 2007 5:35 pm
- Location: Genève
- Contact:
Re: how build url web for a file name with accented letter ?
Thanks a lot Jacque
That is the way for LC 6.7
That is the way for LC 6.7
https://alternatic.ch
-
- VIP Livecode Opensource Backer
- Posts: 2718
- Joined: Sat Dec 22, 2007 5:35 pm
- Location: Genève
- Contact:
Re: build url web for a file name with accented letter solved
Hi All,
It seems something changed about this.
url file name on server for "zéro_2.png" = "ze%CC%81ro_2.png"
I tried this
return "z%C3%A9ro_2.png" instead "ze%CC%81ro_2.png"
Thanks in advance for your help
Jean-Marc
It seems something changed about this.
url file name on server for "zéro_2.png" = "ze%CC%81ro_2.png"
I tried this
Code: Select all
get "zéro_2.png"
put urlEncode(unidecode(uniencode(it), "UTF8"))
Thanks in advance for your help
Jean-Marc
https://alternatic.ch
-
- VIP Livecode Opensource Backer
- Posts: 7228
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: build url web for a file name with accented letter
Maybe you have to go back to textEncode?
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
-
- VIP Livecode Opensource Backer
- Posts: 2718
- Joined: Sat Dec 22, 2007 5:35 pm
- Location: Genève
- Contact:
Re: build url web for a file name with accented letter
Thanks again Jacqueline
We have tested on a ownCloud and it works with this:
No idea why our site does different encoding
P.S: my hight score on Klondike is 840. What is the max score ?
We have tested on a ownCloud and it works with this:
Code: Select all
get "zéro_2.png"
put textencode(it,"UTF-8") into tTE
put urlEncode(tTE) into tUrltTE
replace "+" with "%20" in tUrltTE
P.S: my hight score on Klondike is 840. What is the max score ?
https://alternatic.ch
-
- VIP Livecode Opensource Backer
- Posts: 7228
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: build url web for a file name with accented letter
LOL. I can't remember but I think you're close.my hight score on Klondike is 840. What is the max score ?
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
-
- Livecode Opensource Backer
- Posts: 9359
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria