CodecViewer
Encode/decode viewer ~/tools/codec $ ./transform
Select encoding:
Operation mode:
input.txt
output.txt
📖
URL encoding (Percent-Encoding)
**Use cases**: Safely transmit special characters in URLs (spaces, non-ASCII, `&`, `?`, etc.). Required when building query strings from user input—search keywords, redirects, OAuth callbacks, and GET parameters.
**How it works**: Non-ASCII and reserved URL characters become `%XX`, where XX is the hex byte. Space becomes `%20`; Chinese「你好」becomes `%E4%BD%A0%E5%A5%BD`. Reserved characters like `:/?#[]@` must be escaped when used as data.
Examples:
Input
你好 World!Output
%E4%BD%A0%E5%A5%BD%20World!Basic Codec
Text can be represented in many byte encodings beyond UTF-8—Latin-1, UTF-16, escaped Unicode. This viewer translates sample strings between representations to debug mojibake, email headers, and legacy files when logs show replacement characters.
How to use
- Paste the ambiguous text or byte sequence from your bug report.
- Select source and target encodings (UTF-8 vs UTF-16 LE, URL escapes, etc.).
- Compare outputs and align your parser, database client, or HTTP header configuration with the correct charset declaration.
FAQ
- What is mojibake?
- Garbled text from decoding bytes with the wrong charset—common when UTF-8 data is read as Latin-1. Fix by re-reading with the proper encoding and declaring `charset=utf-8` in HTTP.
- How is this different from Base64?
- Base64 encodes arbitrary bytes into ASCII text; character encodings map human characters to bytes. You may stack both when sending binary in JSON.
- Can I detect encoding automatically?
- Heuristics exist but are imperfect; BOM hints, declared HTTP charset, and producer documentation beat guessing for production pipelines.