All Rounder Tools Blogger-Best blog for blogger: Binary to ASCII converter Tool with colorful styling and all its features use any free library...

Wednesday, September 25, 2024

Binary to ASCII converter Tool with colorful styling and all its features use any free library...

 

Binary to ASCII Converter

Binary to ASCII Converter

ASCII Output

body { font-family: Arial, sans-serif; background-color: #f4f4f9; color: #333; margin: 0; padding: 0; } .container { max-width: 600px; margin: auto; padding: 20px; border-radius: 10px; background: linear-gradient(135deg, #74ebd5, #acb6e5); box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1); } h1 { text-align: center; color: #fff; } textarea { width: 100%; height: 150px; padding: 10px; border: 2px solid #fff; border-radius: 5px; resize: none; font-size: 16px; } textarea:focus { outline: none; border-color: #f8e2a1; } button { display: block; width: 100%; padding: 10px; margin: 20px 0; border: none; border-radius: 5px; background-color: #ff6f61; color: white; font-size: 16px; cursor: pointer; transition: background-color 0.3s; } button:hover { background-color: #ff4a3b; } .output { padding: 10px; border: 2px solid #fff; border-radius: 5px; background-color: #fff; font-size: 18px; word-wrap: break-word; min-height: 50px; } document.getElementById('convertButton').addEventListener('click', function() { const binaryInput = document.getElementById('binaryInput').value.trim(); const asciiOutput = document.getElementById('asciiOutput'); // Clear previous output asciiOutput.innerHTML = ''; if (binaryInput === '') { asciiOutput.innerHTML = 'Please enter binary code.'; return; } // Split the input into chunks of 8 (1 byte) const binaryArray = binaryInput.split(' '); let asciiString = ''; // Convert each binary byte to ASCII binaryArray.forEach(binary => { if (binary.length === 8 && /^[01]+$/.test(binary)) { asciiString += String.fromCharCode(parseInt(binary, 2)); } else { asciiString += '?'; // Placeholder for invalid binary } }); // Display the output asciiOutput.innerHTML = asciiString || 'Invalid binary input.'; });

No comments:

Post a Comment