javascript中的unicode / ascii代码 [英] unicode/ascii codes in javascript

查看:51
本文介绍了javascript中的unicode / ascii代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



伙计,


我有两个相关的问题:


1.我看到unicode正在在我的javascript口袋书中提到 -

这和ascii代码一样吗?我想虽然我不确定但是我没有找到任何例子......


2.我如何阅读/设置一个字符串到一个不可打印的代码?例如,

如何设置变量a等于ascii代码7或8或

的等价物......


为什么?我正在开发一个应用程序,允许用户输入

多个名字 - 我想将这些多个名字存储在隐藏文本中

框中使用不可打印的字符作为每个输入的字段分别

文本字段值。我100%知道我的键盘输入将是

ascii / qwerty。


有人能引导我朝着正确的方向前进吗?

randelld


Folks,

I have two related questions:

1. I have seen unicode being mentioned in my javascript pocket book - is
this the same as ascii codes? I think not though I''m not sure and I
can''t find any examples...

2. How do I read/set a string to an unprintable code? For example, how
can I set the variable a to equal the equivalent of ascii code 7 or 8 or
whatever...

Why? I am working on an application which allows the user to enter in
multiple names - I want to store these multiple names in a hidden text
box using a none-printable character as a field seperate for each input
text field value. I know 100% that my keyboard entries will be
ascii/qwerty.

Can someone steer me in the right direction?

randelld

推荐答案

> 1.我在javascript口袋书中看到过unicode - 是
> 1. I have seen unicode being mentioned in my javascript pocket book - is
这与ascii代码相同吗?我想虽然我不确定但是我找不到任何例子......


ASCII是Unicode的一个子集。买一本更好的书。

2.如何读取/设置字符串为不可打印的代码?例如,如何将变量a设置为等于ascii代码7或8或
等等......

为什么?我正在开发一个允许用户输入多个名字的应用程序 - 我想将这些多个名字存储在一个隐藏文本
框中,使用不可打印的字符作为每个输入的字段单独
文本字段值。我100%知道我的键盘输入将是
ascii / qwerty。

有人可以引导我朝正确的方向发展吗?
this the same as ascii codes? I think not though I''m not sure and I
can''t find any examples...
ASCII is a subset of Unicode. Buy a better book.
2. How do I read/set a string to an unprintable code? For example, how
can I set the variable a to equal the equivalent of ascii code 7 or 8 or
whatever...

Why? I am working on an application which allows the user to enter in
multiple names - I want to store these multiple names in a hidden text
box using a none-printable character as a field seperate for each input
text field value. I know 100% that my keyboard entries will be
ascii/qwerty.

Can someone steer me in the right direction?




是的不要这样做。这些荒谬的方法无法获得安全保障。

名称列表必须保存在服务器上,绝不保存在客户端。

http://www.crockford.com/javascript/survey.html


Douglas Crockford写道:
Douglas Crockford wrote:
1.我在javascript口袋书中看到过unicode -
是这跟ascii代码一样吗?我想虽然我不确定,但我找不到任何例子......
1. I have seen unicode being mentioned in my javascript pocket book -
is this the same as ascii codes? I think not though I''m not sure and I
can''t find any examples...



ASCII是Unicode的一个子集。买一本更好的书。


ASCII is a subset of Unicode. Buy a better book.

2.如何读取/设置字符串为不可打印的代码?例如,
如何将变量a设置为等于ascii代码7
或8等等......

为什么?我正在开发一个允许用户输入多个名字的应用程序 - 我想将这些多个名字存储在一个隐藏文本
框中,使用不可打印的字符作为每个字段的单独
输入文本字段值。我100%知道我的键盘输入将是
ascii / qwerty。

有人可以引导我朝正确的方向发展吗?
2. How do I read/set a string to an unprintable code? For example,
how can I set the variable a to equal the equivalent of ascii code 7
or 8 or whatever...

Why? I am working on an application which allows the user to enter in
multiple names - I want to store these multiple names in a hidden text
box using a none-printable character as a field seperate for each
input text field value. I know 100% that my keyboard entries will be
ascii/qwerty.

Can someone steer me in the right direction?



是的。不要这样做。这些荒谬的方法无法获得安全保障。
名称列表必须保存在服务器上,绝不保存在客户端。

http://www.crockford.com/javascript/survey.html



谢谢 - 我知道安全问题 - 但安全性不是问题

因为我正在开发一个基于内部网的小应用程序 -

另外,我将使用PHP清理我的输入...


因此 - 你能回答我的第二个问题吗?我怎样才能将变量设为

相当于ascii代码7或8或其他什么 - 我相信我可以读取一个

字符串,并找到每个变量的unicode值性格,但我不知道

我可以使用什么功能来反过来这个过程。


欢呼

randelld


Thanks - I am aware of security concerns - but security is not a problem
for me as I''m working on a small intranet based application - in
addition, I will sanitize my input using PHP...

Thus - canyou answer my second question? How can I sest a variable to be
the equivalent of ascii code 7 or 8 or whatever - I believe I can read a
string, and find the unicode values of each character, but I don''t know
what function I can use for the reverse of this process.

cheers
randelld


Douglas Crockford写道:
Douglas Crockford wrote:
1.我在javascript口袋书中看到过unicode -
这和ascii代码一样吗?我想虽然我不确定,但我找不到任何例子......
1. I have seen unicode being mentioned in my javascript pocket book -
is this the same as ascii codes? I think not though I''m not sure and I
can''t find any examples...



ASCII是Unicode的一个子集。买一本更好的书。


ASCII is a subset of Unicode. Buy a better book.

2.如何读取/设置字符串为不可打印的代码?例如,
如何将变量a设置为等于ascii代码7
或8等等......

为什么?我正在开发一个允许用户输入多个名字的应用程序 - 我想将这些多个名字存储在一个隐藏文本
框中,使用不可打印的字符作为每个字段的单独
输入文本字段值。我100%知道我的键盘输入将是
ascii / qwerty。

有人可以引导我朝正确的方向发展吗?
2. How do I read/set a string to an unprintable code? For example,
how can I set the variable a to equal the equivalent of ascii code 7
or 8 or whatever...

Why? I am working on an application which allows the user to enter in
multiple names - I want to store these multiple names in a hidden text
box using a none-printable character as a field seperate for each
input text field value. I know 100% that my keyboard entries will be
ascii/qwerty.

Can someone steer me in the right direction?



是的。不要这样做。这些荒谬的方法无法获得安全保障。
名称列表必须保存在服务器上,绝不保存在客户端。

http://www.crockford.com/javascript/survey.html




啊!我刚刚意识到你也误解了我的第二个问题......我不想把这些名字写成

javascript的一部分...我同意,这会很傻......


我有一个表格 - 它有INPUT标签,要求输入名字和姓氏。


我还有一个隐藏的输入框。


当用户输入名字和姓氏时,我有一个onClick

函数,它接受来自firstname / lastname框,

将其写入隐藏的输入框。我想要这样,因为客户可以一次输入多个名字,而不必每次发布表格

时间。一旦完成输入名称,用户点击

提交按钮,然后将隐藏的输入框传递给我的基于php的服务器。


按顺序为了我的PHP脚本读取输入,我希望隐藏的文本框

有一个固定的格式 - 因此,例如,始终遵循firstname

由ascii字符8接着是姓氏。然后,我可以轻松地在服务器端解开

这个长字符串。


因此 - 你能告诉我如何设置一个名为fs的变量等于ascii

字符8?甚至是unicode角色8? (它不一定是8 - 但是

qwerty键盘输入不能提供的东西)


谢谢

Randell D.



Ah! I''ve just realised that you have have also mis-understood my second
question... I do not want to have the names written as part of the
javascript... this I would agree, would be silly...

I have a form - it has INPUT tags asking for firstname and lastname.

I also have a hidden input box.

When the user enters a firstname and lastname, I have an onClick
function which takes the input from the firstname/lastname box, and
writes it to the hidden input box. I want this so as the client can
enter several names all at once without having to post the form each
time. Once they have finished inputing the names, the user clicks on a
submit button which then passes the hidden input box to my php based server.

In order for my php script to read the input, I want the hidden text box
to have a fixed format - thus, for example, firstname is always followed
by ascii character 8 followed by lastname. I can then easily unpack
this long string on the server side.

Thus - can you tell me how I can set a variable called fs equal to ascii
character 8? Or even unicode character 8? (It doesn''t have to be 8 - but
something not readily available from qwerty keyboard input)

Thanks
Randell D.


这篇关于javascript中的unicode / ascii代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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