Pot.js で利用可能。 PotLite.js では利用できません。
UTF-8 エンコードをします。
文字列 string を UTF-8 エンコードして返します。
Pot.globalize() が適応されている場合、Pot.utf8Encode() が utf8Encode() で実行できます。
UTF-8 エンコードされた文字列が返ります。
var string = 'abcほげ'; var encoded = Pot.utf8Encode(string); var decoded = Pot.utf8Decode(encoded); var toCharCode = function(s) { return Pot.map(s.split(''), function(c) { return c.charCodeAt(0); }); }; Pot.debug(toCharCode(string)); // [97, 98, 99, 12411, 12370] Pot.debug(toCharCode(encoded)); // [97, 98, 99, 227, 129, 187, 227, 129, 146] Pot.debug(string === decoded); // true