Sign In Register

How can we help you today?

Start a new topic

chinese characters in custom callback

we are using google apps script to pull game data into spreadsheet for analysis. we tried using the REST API to query the mongodb directly, and the chinese characters in the data are returned correctly (see rest.png). 

but since the REST API can be used destructively, we needed to switch to custom callbacks for better security. however, when we passed the same data using (see code.png):

Spark.setScriptData("RESPONSE_RAW", result);


Spark.setScriptData("result", result)

all that the spreadsheet received were question marks "?" in place of the chinese characters. even the raw binary array is all question marks "63". (see callback.png). 

we have used Spark.setScriptData to send chinese characters to the unity SDK, and that worked perfectly, and we have used google apps script to query via the REST API, which also works fine. so the problems lies in some encoding compatibility between the custom callback and the google apps script, but i'm stumped. would appreciate any help on the subject. thanks!

here is the google spreadsheet with the test script (only the script is relevant, the spreadsheet content is not). cheers!

(74.3 KB)
(226 KB)
(351 KB)

Hi Hamlet,

We converted this to a ticket so you can check that for a response. When we come up with a suitable solution I'll post it here for the benefit of other users.



Hi Hamlet,

Just posting the solution here for the benefit of other users.

If you use JavaScripts encodeURIComponent method you should be able to get the correct characters in the response. You can test with the following and let me know if it works for you. Try this in the body of your callback.


 "message": "你好"


Now in the callback script itself add the following.


var messageObject = JSON.parse(Spark.getData().REQUEST_BODY)

var encodedString = (encode_utf8(messageObject.message))

Spark.setScriptData("RESPONSE_RAW", encodedString);

//Spark.setScriptData("output", encodedString)

function encode_utf8(s) {
   return unescape(encodeURIComponent(s));




Login to post a comment