I use UrlFetch
to get web content in Google AppsScript.
Problem is that the content I get is:
Kurulu\u015f Osman - \u0627\u0644\u0645\u0624\u0633\u0633 \u0639\u062b\u0645\u0627\u0646
When I use Logger.log(content) I get:
Kuruluş Osman - المؤسس عثمان
This is what I want to get when I do a POST UrlFetchApp.
When I POST the content with UrlFetchApp.fetch(content)
I still get:
Kurulu\u015f Osman - \u0627\u0644\u0645\u0624\u0633\u0633 \u0639\u062b\u0645\u0627\u0646
How to get the Logger.log(content) also being POST:ed with UrlFetchApp command?
Code:
var result = UrlFetchApp.fetch(urlA).getContentText(); // Gives, in Debug mode: Kurulu\u015f Osman - \u0627\u0644\u0645\u0624\u0633\u0633 \u0639\u062b\u0645\u0627\u0646
Logger.log(result); // Gives: Kuruluş Osman - المؤسس عثمان
var payload = JSON.stringify({content: result});
var params = {
method: "POST",
payload: payload,
muteHttpExceptions: true,
contentType: "application/json"
};
UrlFetchApp.fetch(urlB, params);
I get this at the receiving end: Kurulu\u015f Osman - \u0627\u0644\u0645\u0624\u0633\u0633 \u0639\u062b\u0645\u0627\u0646
You have multiple ways of doing so.
The thing is that Unicode is decoded to avoid compatibility errors with different platforms you may want to check your logs in.
It is widespread to have consoles that only support ASCII, for example.
My suggestion is to streamline your logs. I know that this can be annoying, but as soon as you get used to a log platform (Datadog, Sentry, PaperTrail...) this goes always.