convert number or string to ASCII in js
2024-10-19 22:37:17
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 发布文章使用:只允许注册用户才可以访问!
最新文章
- Azure Application Gateway (3) 设置URL路由
- centos 7 相关的一些记录
- 关于readdir返回值中struct dirent.d_type的取值有关问题(转)
- iOS 3D touch 使用技巧
- Swift经典知识整理
- 我也要学iOS逆向工程--函数
- line-height 与垂直居中!
- [AngularJS] Accessing Services from Console
- android 18 Bundle类
- 跨进程发送消息数据(发送WM_COPYDATA消息,够简单的)
- angular--bootstrap实例日期控件【datepicker】
- CMake 教程
- Install Oracle 11gR2 on Debian wheezy(转)
- 老李分享:jvm结构简介 2
- 洛谷P1040 加分二叉树(树形dp)
- 从零开始单排学设计模式「策略模式」黑铁 II
- ASP.NET Web API Basic Identity 中的基本身份验证
- Visio制图之垮职能流程图
- LeetCode160.相交链表
- Python学习笔记之爬虫