Hongmu Notes

🚪 Escape encoding and decoding

Enter the text to get the %XX / %uXXXX encoding string. Enter the encoding string to restore the original text.

Escape encoding and decoding

Instructions for use

  • Encoding: Alphanumeric and @ * _ + - . / remain as they are, and the rest are converted to %XX or %uXXXX
  • Decoding: Restore %uXXXX and %XX into characters, which can be verified back and forth
  • Encoding is not encryption: no key is required, anyone can restore it, do not use it to store sensitive information

%uXXXX encoding

Some fields only accept ASCII characters. Writing Chinese directly will result in an error. After being converted into %uXXXX, it not only meets the restrictions but can be restored downstream.

What it looks like after encoding

Each Chinese character becomes 6 characters: percent sign u plus four hexadecimal digits

"Chinese" gets %u4E2D%20%u6587, where %20 is the space in the middle

Suitable usage scenarios

Only ASCII fields are allowed in the configuration file

Avoid coding inconsistencies resulting in garbled characters when transferring across systems

Length estimate

Each Chinese character occupies 6 characters after encoding. It can be estimated by multiplying the number of characters by 6.

Estimate the length before writing, and you can judge in advance whether the target field can fit.

Don't put the URL

The %u format is not a standard URL encoding. Putting it into the link does not guarantee that it will be correctly recognized.

Please use URL encoding instead when using it for URLs. The results and uses of the two are different.

Will it look different after decoding?

Encoding is reversible, and decoding can restore it to its original state, including punctuation, spaces and line breaks.

Full-width punctuation marks and Chinese characters are both non-ASCII characters and have the same length.

All keywords and tutorials 12

❓ FAQ

What are the four digits after %u?
It is the hexadecimal code point of the character. %u4E2D corresponds to the Chinese character U+4E2D. Four digits are enough to cover commonly used Chinese characters and full-width punctuation.
How many paragraphs are needed for emoticons?
The expression is outside the basic plane and requires two code elements. You will see two segments of %u connected together, which are automatically combined into one character during decoding.