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

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint


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 发布文章使用:只允许注册用户才可以访问!


最新文章

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

热门文章

  1. 接口新建学习---cookie策略
  2. 邮件解析 CNAME记录 A记录 NS记录 MX记录
  3. Python 2.x 和 Python 3.x
  4. CF 板刷总结
  5. Java性能优化,操作系统内核性能调优,JYM优化,Tomcat调优
  6. PHP-文件、目录相关操作
  7. Kwp2000协议的应用(硬件原理使用篇)
  8. IDLE怎么修改背景?
  9. Watering Grass(贪心算法)
  10. c++格式化输入输出以及操纵器的使用