包含所有ASCII字符的字符串 [英] String that contains all ascii characters

查看:122
本文介绍了包含所有ASCII字符的字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在JavaScript中创建一个包含所有ascii字符的字符串.我该怎么办?

I want to create a string in JavaScript that contains all ascii characters. How can I do this?

推荐答案

我的javascript有点生锈,但是类似这样:

My javascript is a bit rusty, but something like this:

s = '';
for( var i = 32; i <= 126; i++ )
{
    s += String.fromCharCode( i );
}

不确定范围是否正确.

修改:
似乎应该是32到127.调整了.


Seems it should be 32 to 127 then. Adjusted.


由于char 127也不是可打印的字符,因此我们必须将其缩小到32< = c< = 126,而不是32< = c< = 127.

Edit 2:
Since char 127 isn't a printable character either, we'll have to narrow it down to 32 <= c <= 126, in stead of 32 <= c <= 127.

这篇关于包含所有ASCII字符的字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆