function encode(text, charset) {
	if (!charset) {
		charset = settings.value.defaultFileEncoding;
	}

	charset = getEncoding(charset).name;
	return execEncode(text, charset);
}
Encodes text to ArrayBuffer according given encoding type
@param {string} text
@param {string} charset
@returns {Promise<ArrayBuffer>}