convert number or string to ASCII in js
ASCII dictionary generator
// const dict = `abcdefghijklmnopqrstuvwxyz`;
const begin = `a`.charCodeAt();
const end = `z`.charCodeAt();
let dict = ``;
for (let i = begin; i < end; i++) {
dict += String.fromCodePoint(i);
}
log(`dict =`, dict);
// dict = abcdefghijklmnopqrstuvwxy
String.fromCodePoint
number or string to ASCII
String.fromCodePoint(65);
//"A"
String.fromCodePoint(`65`);
//"A"
String.fromCharCode
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode
String.fromCharCode(65)
// "A"
String.fromCharCode(`65`);
// "A"
``. codePointAt
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/codePointAt
const icons = 'ab';
console.log(icons.codePointAt());
console.log(icons.codePointAt(0));
console.log(icons.codePointAt(1));
// 97
// 97
// 98
``.charCodeAt
ASCII character to number
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charCodeAt
`a`.charCodeAt();
// 97
`z`.charCodeAt();
// 122
`A`.charCodeAt();
// 65
`Z`.charCodeAt();
// 90
ASCII Table
printable ASCII characters
refs
https://leetcode.com/problems/valid-palindrome/
https://leetcode.com/submissions/detail/368171836/
http://facweb.cs.depaul.edu/sjost/it212/documents/ascii-pr.htm

xgqfrms 2012-2020
www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!