---
title: "js ascii和字符互相转换"
author: "onlyor"
date: "2014-05-28T08:41:50Z"
tags: []
categories: ["Web前端"]
slug: "js-ascii"
draft: false
lastmod: "2014-05-27T17:01:30Z"
id: 2072207
url: "https://onlyor.iteye.com/blog/2072207"
---

**ascii和字符相****互转换**

 

用String.fromCharCode()和String.charCodeAt()

 

1 ascii 转 字符

String.fromCharCode(**98**)

结果：b

 

2 字符 转 ascii

"**a**".charCodeAt(0)    

结果：97

 

属于asc范围的获取的是asciii,如果超出了asciii的表达范围就是unicode