站点介绍

Last week I spent an evening debugging a share link for someone: a long URL with Chinese parameters went into a QR generator, and every scan came back 400. The culprit turned out to be unencoded spaces and CJK characters - the receiving end parsed raw bytes and the URL just broke. This page was built to that evening's spec: paste, convert, pick a mode, and get honest errors when something is off.
URL encoding first splits the string into UTF-8 bytes; a CJK character is usually 3 bytes, and each byte becomes %XX. The UTF-8 bytes of one common character are E4 BD A0, hence %E4%BD%A0 - nine characters representing one glyph, which is normal. Most emoji are 4 bytes, producing 12 characters.
Once that clicks, the "shorter is better" obsession can rest: length is dictated by the encoding rules, not by the tool being lazy.
One sentence to remember: encode values with full mode, encode whole URLs with structure-preserving mode. Search terms, notes, usernames - anything going into a query string - belong to encodeURIComponent, which also converts & = ? # so special characters inside a value cannot break the URL structure. A fully assembled link that just needs its CJK characters converted belongs to encodeURI, which keeps the structure characters intact. When in doubt, try both and paste the result into an address bar.
Rule of thumb: encode a parameter value with encodeURIComponent, encode a whole URL with encodeURI. encodeURIComponent also converts &, =, ? and # into %XX so special characters inside a value cannot break the URL structure; encodeURI leaves those intact and only converts characters that are outright illegal in a URL, like spaces and non-ASCII text. When in doubt, try both - paste each result into a browser address bar and see which one survives.
Your input contains something like %ZZ or %G1 - characters after the percent sign that are not valid hexadecimal - or a % with fewer than two characters following it. Plenty of online tools quietly skip or pass those through; this page raises an error and points at the first offending position instead, because a broken escape usually means the link you copied was truncated or mangled somewhere. Fix the % (escape it as %25) or remove the damaged fragment, then retry.
URL encoding first splits the string into UTF-8 bytes. A CJK character is usually 3 bytes, and each byte becomes one %XX triplet - so 3 bytes times 3 characters each equals 9. Emoji run longer: most are 4 bytes, producing 12 characters. That is not a bug; it is exactly what RFC 3986 prescribes.
They did not change here. That behavior comes from the legacy application/x-www-form-urlencoded format, which encodes spaces as + and decodes + back to spaces. Pure URL percent-encoding (RFC 3986) writes spaces as %20 and treats + as a literal plus. This tool follows RFC 3986 and keeps + as-is; if your data came from an old form submission, replace + with %20 before decoding here.
No. Encoding and decoding happen entirely inside this device's browser - there is no upload endpoint and it works offline. Only your mode preference lives in this browser's localStorage; it does not follow you to another device, and "Clear my data" in the footer removes it.
中文版:https://www.9314.cn/tools/url-encoder/
评论列表 (0条)