如何从ascii值中获取字符. [英] How to get charactor from ascii value.

查看:76
本文介绍了如何从ascii值中获取字符.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hai Friends

我如何尝试从ascii值中获取字符,我尝试了这段代码,但是当iam传递了超过128个ascii值时,它返回?".如何将其转换?还有其他方法可以做到这一点吗?请帮帮我..


Hai Friends

How to get a charactor from an ascii value, i tried this code, but when iam passed more than 128 ascii value it return ''?'' .How to convert it? is there is any other method to do this ? please help me..


public string GetString(byte ascValue)
       {
           ASCIIEncoding ascii = new ASCIIEncoding();
           byte[] asc = new byte[1];
           asc[0] = ascValue;
           string str = ascii.GetString(asc);
           return str;
       }

推荐答案

这是因为编码器中的WindowsCodePage属性(由操作系统设置).我想您可能想改用UTF8Encoding对象.
It''s because of the WindowsCodePage property (set by the OS) in the encoder. I think you might want to use the UTF8Encoding object instead.



使用Chr功能.以下是示例-
Chr(120)返回x.

Hi,
Use Chr Function. Following is an Example-
Chr(120) Returns x.
Or
MessageBox.Show(Chr(120));


这篇关于如何从ascii值中获取字符.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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