Home PHP String Functions convert_uudecode() PHP convert_uudecode() Function Definition In PHP, convert_uudecode() decodes a uuencoded string back into the original binary data.
You pass the encoded string. It is required. Pair it with convert_uuencode() for round-trips.
Syntax Call convert_uudecode on the encoded text. Start with this line.
$bin = convert_uudecode($encoded); Call What it does convert_uudecode($encoded)Restores the original bytes. convert_uuencode($bin)Encodes binary for transport.
Invalid uuencoded input can return false or unexpected data—validate first.
Library declarations convert_uudecode(string $data): string|false Parameters Parameter Description data Required. The uuencoded string to decode.
Return Value Return Value Description string|false Decoded binary data, or false on failure.
PHP Examples 1. Round-trip 2. Check for false 3. Binary-safe bytes Example 1 — Encode, Then Decode The safest way to learn: create uuencode with convert_uuencode(), then reverse it.
<?php
$original = "Hello";
$encoded = convert_uuencode($original);
$decoded = convert_uudecode($encoded);
echo $decoded;
// Hello How It Works Start. $original is plain text Hello.Encode. convert_uuencode() turns it into printable ASCII.Decode. convert_uudecode() restores the bytes.Match. $decoded equals Hello again.Example 2 — Handle Invalid Input Always check for false before treating the result as a string.
<?php
$result = convert_uudecode("not uuencoded text");
if ($result === false) {
echo "decode failed";
} else {
echo $result;
}
// decode failed How It Works Bad input. Plain text is not valid uuencode.Call. convert_uudecode() fails and returns false.Strict check. Use === false (decoded data could be empty string).Branch. Print an error instead of echoing false as empty.Example 3 — Round-Trip Binary Bytes uuencode is binary-safe—NUL and non-text bytes survive a round-trip.
<?php
$raw = "A" . chr(0) . "B";
$back = convert_uudecode(convert_uuencode($raw));
echo strlen($back) . "\n"; // 3
echo ($back === $raw) ? "same" : "diff";
// 3
// same How It Works Build bytes. A, a NUL byte (chr(0)), then B.Round-trip. Encode then decode in one expression.Length. Still 3 bytes—NUL was preserved.Equality. $back === $raw confirms an exact restore.Frequently Asked Questions What does PHP convert_uudecode() do? convert_uudecode() decodes a string that was encoded with the uuencode algorithm, returning the original binary or text data. It reverses the encoding performed by convert_uuencode().
What is the syntax for convert_uudecode()? string|false convert_uudecode(string $string). You pass the uuencoded string and receive the decoded data, or false if decoding fails.
What is uuencode? uuencode is a legacy Unix binary-to-text encoding. It represents binary data as printable ASCII so it could travel through email and text-only channels before Base64 became the common standard.
What is the difference between convert_uudecode() and base64_decode()? convert_uudecode() handles the older uuencode format. base64_decode() handles Base64, which is the modern standard for encoding binary data in email, JSON, and web APIs.
When should I use convert_uudecode()? Use it when reading legacy uuencoded data or maintaining old code. For new projects, prefer Base64 with base64_encode() and base64_decode().
CODETOFUN NEWS
Stay Ahead in Tech Get the latest IT news, programming updates, and technology trends directly on your phone.
About the author Developer, cloud engineer, and technical writer
I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.
9 people found this page helpful
Helpful Share Copy link Suggestion