“Binär in String JavaScript konvertieren” Code-Antworten

Binärum in SMS JS konvertieren

function binaryAgent(str) {

var newBin = str.split(" ");
var binCode = [];

for (i = 0; i < newBin.length; i++) {
    binCode.push(String.fromCharCode(parseInt(newBin[i], 2)));
  }
return binCode.join("");
}
binaryAgent('01000001 01110010 01100101 01101110 00100111 01110100');
//translates to "Aren't"
Silly Skunk

Binär bis ASCII JavaScript

const binaryAgent = str => str.replace(/\d+./g, char => String.fromCharCode(`0b${char}`));
Yawning Yacare

Bin to Bit String JavaScript

function dec2Bin(dec)
{
    if(dec >= 0) {
        return dec.toString(2);
    }
    else {
        /* Here you could represent the number in 2s compliment but this is not what 
           JS uses as its not sure how many bits are in your number range. There are 
           some suggestions https://stackoverflow.com/questions/10936600/javascript-decimal-to-binary-64-bit 
        */
        return (~dec).toString(2);
    }
}
Hilarious Hummingbird

Binär in String JavaScript konvertieren

function binaryAgent(str) {
  const bytes = str.split(' ')
  let output = ''
    
  for (let k = 0; k < bytes.length; k++){
      output += String.fromCharCode(parseInt(bytes[k], 2))
  }
  
  return output
}

binaryAgent("01000001 01110010 01100101 01101110 00100111 01110100 00100000 01100010 01101111 01101110 01100110 01101001 01110010 01100101 01110011 00100000 01100110 01110101 01101110 00100001 00111111");
yunielrc

Ähnliche Antworten wie “Binär in String JavaScript konvertieren”

Fragen ähnlich wie “Binär in String JavaScript konvertieren”

Weitere verwandte Antworten zu “Binär in String JavaScript konvertieren” auf JavaScript

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen