如何使用ascii值在asp.net中进行编码 [英] how to use ascii values for coding in asp.net

查看:66
本文介绍了如何使用ascii值在asp.net中进行编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

int ascii = Convert.ToInt16(e.KeyChar); 
          if (ascii == 13)
          {
             DropDownList2.SelectedIndex = 0;
             DropDownList2.Focus();
}





how to do ascii code in asp.net using c#?

推荐答案

您不需要ASCII!而且您的16位char值不是ASCII.例如:

You don''t need ASCII! And your 16-bit char value is not ASCII. For example:

if (e.KeyCode == keys.Enter) //...



KeyCode的级别较低.它提供了来自硬件扫描代码的第二级密钥处理的密钥数据.在此级别上,字符不是可以计算的.这是Windows原始的原始密钥代码,第一个软件"级别.

NET中根本不使用ASCII.更确切地说,它用作编码,因此您可以将Unicode文本作为ASCII序列化为字节数组,但是某些代码点可能会丢失(那些位于0..127之外的代码点).您根本无法将字符与ASCII代码进行比较:单个字符占用不同数量的字节,具体取决于代码点和编码,这里完全不涉及.

务必避免使用ASCII;时间已经过去了.

—SA



The level of KeyCode is lower level. It provides a key data on the second level of key processing from hardware scan code. At this level, the character is not yes calculated. This is a raw Windows-specific key code, first "software" level.

ASCII is not used in .NET at all. More exactly, it is used as encoding, so you can serialize Unicode text as ASCII into array of bytes, but some code points can be lost (those outside 0..127). You cannot compare character with ASCII code at all: a single character takes different number of bytes, depending on code point and encoding, which is not involved here at all.

Avoid ASCII by all means; its time has gone.

—SA




这篇关于如何使用ascii值在asp.net中进行编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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