urlDecode specials chars

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Jean-marc Radigois
Posts: 10
Joined: Mon Aug 26, 2013 6:49 pm

urlDecode specials chars

Post by Jean-marc Radigois » Fri Jul 31, 2015 10:56 am

to read the content of a folder, I use "put UrlDecode(the detailed files)". One of the files is named "délai.pdf". With LiveCode 5.5.5, I obtain "délai.pdf"; with LiveCode 7.0.6 I obtain ""de?lai.pdf" (I use Mac OS X 10.10.4). Wath is wrong ? any can help ? thanks

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: urlDecode specials chars

Post by jmburnod » Fri Jul 31, 2015 12:15 pm

Hi Jean-Marc
I regulary meet strange results with file name with accented chars.
I got the same result with your example
If read a folder content is the goal, I wonder if you need detailed files.
Why not use just "the files" ?
I suppose there is a unicode way and I am sure one livecoder coming soon with a unicode way
Best regards
Jean-Marc
https://alternatic.ch

Jean-marc Radigois
Posts: 10
Joined: Mon Aug 26, 2013 6:49 pm

Re: urlDecode specials chars

Post by Jean-marc Radigois » Fri Jul 31, 2015 1:45 pm

thanks Jean-Marc,
I use detailed files because I need to known the size of the file and its date creation.
Because of your response, I have reported a bug (I don't know if this bug is repaired since Livecode 7 that I use).

My bug's report:
if a file's name contents an accented char as "é" the detailed files reports the name of this char as "e%3F" and not "%8E". So when you use urlDecode of this char, you do not obtains "é" but "e?".
The LiveCode 5.5.5 gives a good value, but not LiveCode 7.0.4
Notice that the result of "the files" (and not the detailed files) gives a good answer.

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: urlDecode specials chars

Post by jmburnod » Fri Jul 31, 2015 2:26 pm

I worked for a function GetSizeOneFile and it works for me.
The trick seems encode the name of the file and search it in detailed files
I hope that is the case for you

Code: Select all

on mouseUp
   answer file "Open file"
   if it = empty then exit mouseup
   put it into tPathFile
   set the itemdel to "/"
   put item 1 to -2 of tPathFile into tPathFol
   put item -1 of tPathFile into tNameFile
   set the itemdel to ","
   put urlencode(tNameFile) into tNameFileUrl
   set the defaultfolder to tPathFol
   put the detailed files into tDetFilesS
   put GetSizeOneFile(tNameFileUrl,tDetFilesS)
end mouseUp

function GetSizeOneFile pNameFi,pDetFilesS
   put empty into rGetSizeOneFile
   put lineoffset(pNameFi,pDetFilesS) into tFoundLi
   get line tFoundLi of pDetFilesS
   put item 2 of it into tSize1
   put item 3 of it into tSize2 
   put tSize1 & "," & tSize2 into rGetSizeOneFile
   return rGetSizeOneFile
end GetSizeOneFile
https://alternatic.ch

Jean-marc Radigois
Posts: 10
Joined: Mon Aug 26, 2013 6:49 pm

Re: urlDecode specials chars

Post by Jean-marc Radigois » Sat Aug 01, 2015 8:33 am

Thanks Jean-Marc for your contribution
I have understood an origine of the problem illustrated there:
Photo.png

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: urlDecode specials chars

Post by jmburnod » Sat Aug 08, 2015 5:29 pm

I have understood an origine of the problem illustrated there:
OK, but did you solve it ?
Best regards
Jean-Marc
https://alternatic.ch

Post Reply