マルチバイト文字, fromCharCode, charCodeAt, Unicode

マルチバイト文字かどうか確認

/**
 * UTF-8における、1Byte以外の文字かどうか
 * -> 0-127 (ASCII 文字セット) 以外
 */
function hasMultibyte(str) {
  return /[^\u0000-\u007f]/.test(str);
}
hasMultibyte('a');
// -> false
hasMultibyte('>');
// -> false
hasMultibyte('ÿ');
// -> true
hasMultibyte('あ');
// -> true

fromCharCode

String.fromCharCode() - JavaScript | MDN

returns a string created by using the specified sequence of Unicode values

String.fromCharCode(0x3e)
// -> '>'
String.fromCharCode(62)
// -> '>'
(62).toString(16)
// -> '3e'

charCodeAt

String.prototype.charCodeAt() - JavaScript | MDN

returns an integer between 0 and 65535 representing the UTF-16 code unit at the given index

'>'.charCodeAt(0)
// -> 62
'\u003E'.charCodeAt(0)
// -> 62
'>'.charCodeAt(0).toString(16)
// -> '3e'

Unicode

その他参考