二进制字符串ASCII文本字符串 [英] Binary String to ASCII TEXT String

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

问题描述


  

可能重复:结果
  <一href=\"http://stackoverflow.com/questions/6006425/binary-to-corresponding-ascii-string-conversion\">Binary为了对应的ASCII字符串转换


我之前发布了slimier的问题,但没有得到一个正确的答案。

我的问题是,我有一个二进制字符串作为

<$p$p><$c$c>00100000011101110110000101101110011101000010000001110100011011110010000001100100011011110111

这需要即时通讯转换为普通的ASCII字符串文本

我用 BinaryReader 和阅读并设有code System.Text.ASCIIEncoding.ASCII ,但即时得到同样 0101010 字符串

 字节[]字节组= b.ReadBytes((int)的长度);    System.Text.Encoding encEn codeR = System.Text.ASCIIEncoding.ASCII;    字符串BB = encEn coder.GetString(ByteArray的);

任何帮助将不胜感激!


解决方案

首先转换二进制字符串转换为字节[] 使用<一个href=\"http://stackoverflow.com/questions/3935524/how-could-i-en$c$c-a-string-of-1s-and-0s-for-transport\">How我可以带code 1和0运输的字符串?

接下来使用 Convert.ToBase64String 方法得到实际 System.String

Possible Duplicate:
Binary To Corresponding ASCII String Conversion

I posted a slimier question before but didn't got a correct answer..

my problem is i have a binary string as

00100000011101110110000101101110011101000010000001110100011011110010000001100100011011110111

Which im required to convert to "Normal ASCII String Text"

I used BinaryReader and read and encode System.Text.ASCIIEncoding.ASCII but im getting the same 0101010 string

    byte[] bytearray = b.ReadBytes((int)length);

    System.Text.Encoding encEncoder = System.Text.ASCIIEncoding.ASCII;

    string bb = encEncoder.GetString(bytearray);

any help will be grateful !

解决方案

first translate the binary string into a byte[] using How could I encode a string of 1s and 0s for transport?

next use the Convert.ToBase64String method to get the actual System.String

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

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