urlencode() mystery
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- VIP Livecode Opensource Backer
- Posts: 2718
- Joined: Sat Dec 22, 2007 5:35 pm
- Location: Genève
- Contact:
urlencode() mystery
Hi All,
I have to use urlencode function to keep accented letters in file name.
I get different results with file name "zéro.png" in these contexts
1. Typing "zéro.png" with keyboard.
urlencode("zéro.png") return "z%8Ero.png"
2. Get the file name by answer file
urlencode("zéro.png") return "ze%3Fro.png"
I tested : nameFile = nametypedwithkeyboard with casesensitive = true
Any idea ?
Best regards
Jean-Marc
I have to use urlencode function to keep accented letters in file name.
I get different results with file name "zéro.png" in these contexts
1. Typing "zéro.png" with keyboard.
urlencode("zéro.png") return "z%8Ero.png"
2. Get the file name by answer file
urlencode("zéro.png") return "ze%3Fro.png"
I tested : nameFile = nametypedwithkeyboard with casesensitive = true
Any idea ?
Best regards
Jean-Marc
https://alternatic.ch
Re: urlencode() mystery
hi, might be a bug? i think both are incorrect, shouldn't it be z%E9ro.png. Using other langs or online urlencoders, i get z%C3%A9ro.png.
— Mark
— Mark
-
- VIP Livecode Opensource Backer
- Posts: 7237
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: urlencode() mystery
If you are using LC 7 it's probably the difference between the OS unicode format and LC's format. After you get the filename from the answer file dialog, put it through textDecode first before using urlEncode. See if that helps.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: urlencode() mystery
So much for "Unicode, it just works!"
-
- VIP Livecode Opensource Backer
- Posts: 7237
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: urlencode() mystery
It's just how operating systems work. They all use different encodings, so you have to convert from the OS encoding to LC UTF16.
But I agree file names should be converted automatically the same way line endings are. If textDecode works then it could be a bug. If textDecode doesn't work then the problem may not be unicode translation. LC has had problems with unicode file names in the past.
But I agree file names should be converted automatically the same way line endings are. If textDecode works then it could be a bug. If textDecode doesn't work then the problem may not be unicode translation. LC has had problems with unicode file names in the past.
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: urlencode() mystery
Thanks All,
I tried this but it doesn't work for me. Where I'm wrong ?
Jean-Marc
I tried this but it doesn't work for me. Where I'm wrong ?
Code: Select all
on mouseUp
answer file "open file :"--name of selected file = "zéro.png"
set the itemdel to "/"
put item -1 of it into tName
set the itemdel to ","
put textdecode(tName,"UTF-8") into tEncodeName --return "zro.png"
dansmes urlencode(tEncodeName)--return "zro.png"
end mouseUp
https://alternatic.ch
-
- VIP Livecode Opensource Backer
- Posts: 7237
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: urlencode() mystery
The OS encoding may not be UTF8, it's probably native. Use this instead:
put textdecode(tName,"Native") into tEncodeName
The engine will look for the correct encoding for the OS. But I am not completely sure that unicode decoding is the problem, so this is just a test to see if it works. What OS are you running?
put textdecode(tName,"Native") into tEncodeName
The engine will look for the correct encoding for the OS. But I am not completely sure that unicode decoding is the problem, so this is just a test to see if it works. What OS are you running?
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: urlencode() mystery
Thanks one more Jaques,
"Native" seems the magic word
I tried also UTF-16 that return chinese chars
Best regards
Jean-Marc
"Native" seems the magic word
Code: Select all
put textdecode(tName,"Native") into tEncodeName --return "zéro.png"
Code: Select all
put textdecode(tName,"UTF-16") into tEncodeName --return "蹺潲瀮杮"
OS X 10.10.3What OS are you running?
Best regards
Jean-Marc
https://alternatic.ch