http - Sending Arabic characters to Google Sheet -
i sending http request google sheet trying add row of data has arabic characters. works fine when using english characters gets empty cell when using arabic characters. can use following post request in language.
params.body = "pphrase=عربی" network.request( "https://script.google.com/macros/s/111222334445555/exec","post",getfeatured,params)
my google sheet script code receives request , saves abpve params.body row under pphrase column:
// usage // 1. enter sheet name data written below var sheet_name = "sheet1"; // 2. run > setup // // 3. publish > deploy web app // - enter project version name , click 'save new version' // - set security level , enable service (most execute 'me' , access 'anyone, anonymously) // // 4. copy 'current web app url' , post in form/script action // // 5. insert column names on destination sheet matching parameter names of data passing in (exactly matching case) var script_prop = propertiesservice.getscriptproperties(); // new property service // if don't want expose either or post methods can comment out appropriate function function doget(e){ return handleresponse(e); } function dopost(e){ return handleresponse(e); } function handleresponse(e) { // shortly after original solution google announced lockservice[1] // prevents concurrent access overwritting data // [1] http://googleappsdeveloper.blogspot.co.uk/2011/10/concurrency-and-google-apps-script.html // want public lock, 1 locks invocations var lock = lockservice.getpubliclock(); lock.waitlock(30000); // wait 30 seconds before conceding defeat. try { //mailapp.sendemail("m.hawksey@gmail.com", "data", json.stringify(e.parameters)); // next set write data - write multiple/alternate destinations var doc = spreadsheetapp.openbyid(script_prop.getproperty("key")); var sheet = doc.getsheetbyname(sheet_name); // we'll assume header in row 1 can override header_row in get/post data var headrow = e.parameter.header_row || 1; var headers = sheet.getrange(1, 1, 1, sheet.getlastcolumn()).getvalues()[0]; var nextrow = sheet.getlastrow()+1; // next row var row = []; // loop through header columns (i in headers){ if (headers[i] == "timestamp"){ // special case if include 'timestamp' column row.push(new date()); } else { // else use header name data row.push(e.parameter[headers[i]]); } } // more efficient set values [][] array individually sheet.getrange(nextrow, 1, 1, row.length).setvalues([row]); // return json success results return contentservice .createtextoutput(json.stringify({"result":"success", "row": nextrow})) .setmimetype(contentservice.mimetype.json); } catch(e){ // if error return return contentservice .createtextoutput(json.stringify({"result":"error", "error": e})) .setmimetype(contentservice.mimetype.json); } { //release lock lock.releaselock(); } } function setup() { var doc = spreadsheetapp.getactivespreadsheet(); script_prop.setproperty("key", doc.getid()); }
i ended converting arabic characters string of numbers , send numbers google sheet , when getting them convert arabic.
local letters = {"ا","ب", "پ", "ت", "ث", "ج", "چ", "ح", "خ", "د", "ذ", "ر", "ز", "ژ", "س", "ش", "ص", "ض","ط", "ظ", "ع", "غ", "ف", "ق", "ک", "گ", "ل", "م", "ن", "و", "ه", "ی", "\b"} function returnindex( ) j=1,33 if a==letters[j] print(j) joketext=j.." "..joketext end end end local joke = "عربی" = 1, #joke+1 print(string.sub(joke, i, i+1)) returnindex(string.sub(joke, i, i+1)) end
Comments
Post a Comment