<!DOCTYPE html>
<html>
<head>
<title>Binary to Text Converter</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f2f2f2;
}
.container {
display: flex;
flex-direction: column;
align-items: center;
margin-top: 100px;
}
h1 {
color: #333;
margin-bottom: 20px;
}
.text-area {
width: 400px;
height: 200px;
padding: 10px;
border: 2px solid #ccc;
border-radius: 4px;
resize: none;
}
.convert-button {
padding: 10px 20px;
font-size: 16px;
font-weight: bold;
color: #fff;
background-color: #4CAF50;
border: none;
border-radius: 4px;
cursor: pointer;
}
.convert-button:hover {
background-color: #45a049;
}
.result {
margin-top: 20px;
font-size: 18px;
font-weight: bold;
color: #333;
white-space: pre-wrap;
}
@media screen and (max-width: 480px) {
.text-area {
width: 250px;
}
}
</style>
</head>
<body>
<div class="container">
<h1>Binary to Text Converter</h1>
<textarea id="inputBinary" class="text-area" placeholder="Enter binary code"></textarea>
<button onclick="convertToText()" class="convert-button">Convert</button>
<div id="result" class="result"></div>
</div>
<script>
function convertToText() {
var inputBinary = document.getElementById("inputBinary").value;
var binaryArray = inputBinary.trim().split(" ");
var text = "";
for (var i = 0; i < binaryArray.length; i++) {
var binaryChar = binaryArray[i];
var decimalChar = parseInt(binaryChar, 2);
var textChar = String.fromCharCode(decimalChar);
text += textChar;
}
document.getElementById("result").textContent = "Text representation: " + text;
}
</script>
</body>
</html>
Comments
Post a Comment
sunil191280@gmail.com