Re: Text encoding when added to a cell

2019-08-01 Thread Alex Ivanov ✔
It's cool that your problem was solved. Thanks for the best practice!

Best,
Alex.

On Thursday, August 1, 2019 at 10:26:35 AM UTC+3, Dmitri wrote:
>
> At first I thought the problem was in API, but the problem was in the 
> encodings when sending the request POST. Solution to this problem 
> *encodeURIComponent()*. It is enough to encode each transmitted parameter 
> with *encodeURIComponent().*
>
>
> var str = 'm=put=';
> obj = {'B3':'bla-bla (in Russian) to write text'};
> var data = JSON.stringify(obj);
> data = encodeURIComponent(data);
> data = str+data;
>
>
> var link = 'https://script.google.com/macros/s/XX/exec'; // 
> Google Script
> const XMLHttpRequest = Components.Constructor("@
> mozilla.org/xmlextras/xmlhttprequest;1");
> var xhr = XMLHttpRequest();
> xhr.open('POST', link, false);
> xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded; 
> charset=utf-8');
> xhr.send(data);
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Spreadsheets API" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-spreadsheets-api+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-spreadsheets-api/59c045b1-c081-4f9b-94ed-f2a98c4341ae%40googlegroups.com.


Re: Text encoding when added to a cell

2019-08-01 Thread Dmitri
At first I thought the problem was in API, but the problem was in the 
encodings when sending the request POST. Solution to this problem 
*encodeURIComponent()*. It is enough to encode each transmitted parameter 
with *encodeURIComponent().*


var str = 'm=put=';
obj = {'B3':'bla-bla (in Russian) to write text'};
var data = JSON.stringify(obj);
data = encodeURIComponent(data);
data = str+data;


var link = 'https://script.google.com/macros/s/XX/exec'; // Google 
Script
const XMLHttpRequest = Components.Constructor(
"@mozilla.org/xmlextras/xmlhttprequest;1");
var xhr = XMLHttpRequest();
xhr.open('POST', link, false);
xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded; 
charset=utf-8');
xhr.send(data);

-- 
You received this message because you are subscribed to the Google Groups 
"Google Spreadsheets API" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-spreadsheets-api+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-spreadsheets-api/f3650f81-a046-471b-a43f-75ca00a724e2%40googlegroups.com.


Re: Text encoding when added to a cell

2019-07-31 Thread Alex Ivanov ✔
Hi Dmitri

Sorry how this is related to Google Spreadsheets API?

You can ask about Google Apps Script here 
.

Best,
Alex.

On Wednesday, July 31, 2019 at 1:07:34 PM UTC+3, Dmitri wrote:
>
> Hi,
>
> I try to add Russian text to the cell, but adding Russian text is not 
> added. For example, "bla-bla (in Russian) to write text)" adds only "   to 
> write text".
>
> Added encoding UTF-8 when sending
> xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded; 
> charset=UTF-8");
>
> anyway, the Russian text is ignored.
>
> Thanks in advance for the answers
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Spreadsheets API" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-spreadsheets-api+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-spreadsheets-api/fe2a8a84-6c34-4738-a4d4-cf5909fed501%40googlegroups.com.


Re: Text encoding when added to a cell

2019-07-31 Thread Dmitri

>
> If send via the browser, the text is perfectly added.
>

https://script.google.com/macros/s/XX/exec?m=put={"B3":"bla-bla 
(in Russian) to write text"} 

-- 
You received this message because you are subscribed to the Google Groups 
"Google Spreadsheets API" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-spreadsheets-api+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-spreadsheets-api/d34bfc70-dcc2-446c-91ef-1461dfcb2f89%40googlegroups.com.


Re: Text encoding when added to a cell

2019-07-31 Thread Dmitri
Send method is POST

var link = "https://script.google.com/macros/s/XXX/exec;; // Google 
Script
const XMLHttpRequest = Components.Constructor(
"@mozilla.org/xmlextras/xmlhttprequest;1");
var xhr = XMLHttpRequest();
xhr.open('POST', link, false);
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded; 
charset=UTF-8");
xhr.send(_data);



-- 
You received this message because you are subscribed to the Google Groups 
"Google Spreadsheets API" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-spreadsheets-api+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-spreadsheets-api/ee8a3245-4399-4a01-9cb4-8a34d3e4514d%40googlegroups.com.