Pages

Wednesday, 4 December 2024

Octal to Text Converter Tool



Octal to Text Converter

Octal to Text Converter

Converted Text:

Your result will appear here.

* { margin: 0; padding: 0; box-sizing: border-box; } body { font-family: 'Poppins', sans-serif; background-color: #f4f7fc; display: flex; justify-content: center; align-items: center; min-height: 100vh; } .container { background-color: #fff; padding: 30px; border-radius: 10px; box-shadow: 0 0 15px rgba(0, 0, 0, 0.1); text-align: center; width: 100%; max-width: 500px; } h1 { font-size: 2em; color: #4a90e2; margin-bottom: 20px; } .input-container { margin-bottom: 20px; } label { font-size: 1.1em; color: #333; } input { width: 100%; padding: 10px; margin-top: 10px; font-size: 1.2em; border: 2px solid #ccc; border-radius: 5px; outline: none; transition: border-color 0.3s ease; } input:focus { border-color: #4a90e2; } .convert-btn { background-color: #4a90e2; color: white; padding: 12px 20px; border: none; border-radius: 5px; font-size: 1.2em; cursor: pointer; transition: background-color 0.3s ease; } .convert-btn:hover { background-color: #3578b4; } .output-container { margin-top: 30px; } .output-text { font-size: 1.2em; color: #333; font-weight: 500; } // Function to convert Octal to Text function convertOctalToText() { let octalInput = document.getElementById("octal-input").value.trim(); let outputText = document.getElementById("output-text"); if (octalInput === "") { outputText.innerText = "Please enter an octal number."; return; } // Split the input by spaces to handle multiple octal values let octalNumbers = octalInput.split(/\s+/); let text = ""; // Convert each octal value to its character representation for (let i = 0; i < octalNumbers.length; i++) { let octal = octalNumbers[i].trim(); // Ensure the input is a valid octal number if (!/^[0-7]+$/.test(octal)) { outputText.innerText = "Invalid octal number detected."; return; } // Convert octal to decimal let decimalValue = parseInt(octal, 8); // Convert decimal to character (ASCII) text += String.fromCharCode(decimalValue); } // Display the converted text outputText.innerText = text ? text : "Unable to convert octal."; }