textEncode and Google Forms
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- VIP Livecode Opensource Backer
- Posts: 7237
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: textEncode and Google Forms
Would url Encode be of use here? That's what all the percent signs look like.
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: textEncode and Google Forms
We noticed url encode make some fantaisies
https://forums.livecode.com/viewtopic.p ... =urlencode
put urlencode("Ç") = %82
put urldecode("%82") = Ç
but if you copy "Ç" from a file name on finder
put urlencode("Ç") = C%3F
Jean-Marc
https://forums.livecode.com/viewtopic.p ... =urlencode
put urlencode("Ç") = %82
put urldecode("%82") = Ç
but if you copy "Ç" from a file name on finder
put urlencode("Ç") = C%3F
Jean-Marc
https://alternatic.ch
Re: textEncode and Google Forms
Hi Simon,
Out of curiosity, as I do know nothing about google spreadsheets,
I gave a try and here is working solution with French characters.
Screenshot of your google spreadsheet:
and the code:
Part of the story is to please both LC & Google.
Wish you a nice day,
Thierry
Out of curiosity, as I do know nothing about google spreadsheets,
I gave a try and here is working solution with French characters.
Screenshot of your google spreadsheet:
and the code:
Code: Select all
on mouseUp
put "......" into myKey
put "https://docs.google.com/forms/d/" into googleSpreadsheetUrl
put myKey & "/formResponse" after googleSpreadsheetUrl
-- Set http Headers; 1st is mandatory, others I'm not sure
get "Content-Type: application/x-www-form-urlencoded;charset=utf-8" &CRLF
get IT & "Accept-Language: fr-FR" & CRLF
get IT & "Content-Language: fr-FR" & CRLF
set the httpHeaders to IT
put "2 @éè!çàù zzz" into myInput
-- Works fine with datas in LC text field
-- post libURLFormData("entry.2124695200", textEncode( field "Input", "UTF-8" ) ) to URL googleSpreadsheetUrl
-- Works also fine with datas as a script variable
post libURLFormData("entry.2124695200", textEncode( myInput, "UTF-8" ) ) to URL googleSpreadsheetUrl
-- check the result
put IT into url "file:///Users/xx/googleSpreadsheetResult.html"
end mouseUp
Wish you a nice day,
Thierry
Last edited by Thierry on Wed Apr 10, 2019 8:28 am, edited 1 time in total.
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!
-
- Posts: 641
- Joined: Tue Jul 29, 2014 12:52 am
- Location: Brazil
Re: textEncode and Google Forms
Thierry, it works! Well done, I'd have never done it myself.
Thanks god french and portuguese characters are alike...
Many thanks and I'm pretty sure your code will help others in the future.
Abraços!
p.s.: I would like to mention that LC forum members are unbelievable helpful. In my view the forum is probably one of the most valuables attributes of LC. Many thanks to all of you for your contributions.
Thanks god french and portuguese characters are alike...
Many thanks and I'm pretty sure your code will help others in the future.
Abraços!
p.s.: I would like to mention that LC forum members are unbelievable helpful. In my view the forum is probably one of the most valuables attributes of LC. Many thanks to all of you for your contributions.
Simon
________________________________________
To ";" or not to ";" that is the question
________________________________________
To ";" or not to ";" that is the question
Re: textEncode and Google Forms
Yes, we are all from the same rootsimon wrote: Thierry, it works! Well done, I'd have never done it myself.
Thanks god french and portuguese characters are alike...
I believe this will work with any language.... till someone pops up some errors.
I'm glad that it helps you at the first placeMany thanks and I'm pretty sure your code will help others in the future.
Regards,
Thierry
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!
-
- Posts: 641
- Joined: Tue Jul 29, 2014 12:52 am
- Location: Brazil
Re: textEncode and Google Forms
Just to expand on the solution and make it more generic (meaning accepting any language) it I found out (https://developer.mozilla.org/en-US/doc ... t-Language) that replacing
by
would work with any language.
Code: Select all
get IT & "Accept-Language: fr-FR" & CRLF
get IT & "Content-Language: fr-FR" & CRLF
Code: Select all
get IT & "Accept-Language: *" & CRLF
get IT & "Content-Language: *" & CRLF
Simon
________________________________________
To ";" or not to ";" that is the question
________________________________________
To ";" or not to ";" that is the question
Re: textEncode and Google Forms
Simon,Code: Select all
get IT & "Accept-Language: fr-FR" & CRLF get IT & "Content-Language: fr-FR" & CRLF
I've played a bit with my code and it still works getting rid of these 2 lines of script
but keeping the Content-type settings.
Otherwise, I wouldn't follow you on the generic form.
I believe it's more complicated and depends of use-cases...
May be Sparkout could chime in?
Regards.
Thierry
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!
Re: textEncode and Google Forms
Did someone call?
I don't know that I am qualified to assume the go-to mantle here, but AFAIK:
It largely depends on use-cases, as Thierry said.
Content-Language is an entity header (server side) and I believe it doesn't have any meaningful purpose in a request header (client side).
Content-Accept is a request header (client side) that provides information to the content provider of the client browser desired or default language setting. If the server has been set up to provide multiple language settings it can provide language-specific content. In theory the server can refuse to serve content where it doesn't have a matching language configuration to the Content-Accept request. I don't imagine there are many servers set up like that. I believe this request header is more usually interpreted as a request to "give me content in this language if you have it, otherwise just provide the content that is nearest the match if you have been set up that way, otherwise just give me content in whatever language you want".
I am more confident of my first answer. I think you should leave out the Content-Language header. But I think either you can leave out the Content-Accept header too, or leave it with your default language choice, and not worry whether the server has that content value, it should return any content rather than refuse just because you said "French please".
I don't know that I am qualified to assume the go-to mantle here, but AFAIK:
It largely depends on use-cases, as Thierry said.
Content-Language is an entity header (server side) and I believe it doesn't have any meaningful purpose in a request header (client side).
Content-Accept is a request header (client side) that provides information to the content provider of the client browser desired or default language setting. If the server has been set up to provide multiple language settings it can provide language-specific content. In theory the server can refuse to serve content where it doesn't have a matching language configuration to the Content-Accept request. I don't imagine there are many servers set up like that. I believe this request header is more usually interpreted as a request to "give me content in this language if you have it, otherwise just provide the content that is nearest the match if you have been set up that way, otherwise just give me content in whatever language you want".
I am more confident of my first answer. I think you should leave out the Content-Language header. But I think either you can leave out the Content-Accept header too, or leave it with your default language choice, and not worry whether the server has that content value, it should return any content rather than refuse just because you said "French please".
Re: textEncode and Google Forms
Hi Sparkout,SparkOut wrote: Did someone call?
I don't know that I am qualified to assume the go-to mantle here, but AFAIK:
Everyone is the hero of someone or about something...
Thanks for your comment, makes sense.
Interesting, when I started working on Simon's problem, the google answer had wrong characters
for the French part, but afterwards, I got the right wording, like this:
Kind regards,
Thierry
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!