google-apps-script utf8

2020-04-01 06:33发布

问题:

I use the following in a script:

var JSONResult = Maps.newGeocoder().geocode(member.address);
var AddressFormatted= JSONResult.results[0].formatted_address;

and the result is sometime look like

Rue de Cognel��e

I would like to force to have the result in UTF8 charset. How can I do that ?

Vincent

回答1:

You can do charset conversions using Blobs. This example converts "foo" from UTF-8 to UTF-16.

Utilities.newBlob("").setDataFromString("foo", "UTF-8").getDataAsString("UTF-16")