Skip to content

EncodeApp is a GAS library for retrieving the encoding set (charset) and doing URL encode with the specific encoding set using Google Apps Script (GAS).

License

Notifications You must be signed in to change notification settings

tanaikech/EncodeApp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

EncodeApp

MIT License

Overview

EncodeApp is a GAS library for retrieving the encoding set (charset) and doing URL encode with the specific encoding set using Google Apps Script (GAS).

Library's project key

1DsJdRQ9D6nXgbxVVvOroM3EYJOcB197Isvt2Sl4sziW3m9IqqeB9YoWy

Methods

Methods Description
getCharset(blob) Retrieve the encoding set (charset) of the blob.
encodeURIWithCharset(object) URI encode with the specific charset.

Usage:

1. Install library

In order to use this library, please install this library as follows.

  1. Create a GAS project.

    • You can use this library for the GAS project of both the standalone type and the container-bound script type.
  2. Install EncodeApp library.

    • Library's project key is 1DsJdRQ9D6nXgbxVVvOroM3EYJOcB197Isvt2Sl4sziW3m9IqqeB9YoWy.

About scopes

This library use no scopes.

2. Method: getCharset

In this method, the encoding set (charset) is retrieved from the blob. The corresponding list of encoding set is from https://docs.oracle.com/javase/8/docs/technotes/guides/intl/encoding.doc.html is used. In this case, the returned value is the candidate. So when you use this method, several charsets are returned as the candidate.

Sample script

var blob = DriveApp.getFileById("###").getBlob();
var res = EncodeApp.getCharset(blob);
Logger.log(res);

In this sample script, the charset of the file is retrieved.

3. Method: encodeURIWithCharset

In this method, URL encode can be run with the specific charset. At Google Apps Script, when URL encode is run with encodeURI() and encodeURIComponent(), it is run as UTF-8. It seems that this is the specification. In this method, the URL encode can be run by selecting the charset.

Sample script

var object = {
  charset: "Shift-JIS",
  text: "本日は晴天なり"
};
var res = EncodeApp.encodeURIWithCharset(object);
Logger.log(res);

In this sample script, the URL encode is run with Shift-JIS. The following result is retrieved.

{
  "encodedType1": "%96%7B%93%FA%82%CD%90%B0%93%56%82%C8%82%E8",
  "encodedType2": "%96%7B%93%FA%82%CD%90%B0%93V%82%C8%82%E8",
  "blob": Blob,
  "charset": "Shift-JIS"
}

Blob is the blob with the text of 本日は晴天なり converted to Shift-JIS.

Reference:


Licence

MIT

Author

Tanaike

If you have any questions and commissions for me, feel free to tell me.

Update History

  • v1.0.0 (January 24, 2020)

    1. Initial release.

TOP

About

EncodeApp is a GAS library for retrieving the encoding set (charset) and doing URL encode with the specific encoding set using Google Apps Script (GAS).

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published