B
B
bezvozni2020-11-29 15:57:01
Java
bezvozni, 2020-11-29 15:57:01

How to translate the string "01001110" into 1 byte?

Is it only to manually write the translation algorithm?
Or is it simple?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Gornostaev, 2020-11-29
@bezvozni

String s = "01001110";
byte b = Byte.parseByte(s, 2);

T
tsveykat, 2020-11-29
@tsveykat

using System;
using System.Text;
class Program
{
static void Main(string[] args)
{
byte[] str = new byte[] { 0x7B, 0x22, 0x62, 0x61, 0x6C, 0x61, 0x6E,
0x63, 0x65, 0x22, 0x3A, 0x30, 0x2C, 0x22 , 0x62, 0x6F};
Console.WriteLine(Encoding.ASCII.GetString(str));
}
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question