Java url 中 %20 和 %2 之间的差异
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22057083/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
difference between %20 and %2 in url
提问by anathema
The java application that I am developing right now is posting an url and some part of the url is like this:
我现在正在开发的 Java 应用程序正在发布一个 url,该 url 的某些部分是这样的:
asset=travel%2Ccar%2Chouse%2Cbusiness
is there any difference with %20 and %2 in the urls? I know that %20 means spaces but i am a little bit confused when I saw the %2.
url 中的 %20 和 %2 有什么区别吗?我知道 %20 表示空格,但是当我看到 %2 时我有点困惑。
采纳答案by Ghostkeeper
The % indicates an escaped character. It's a hexadecimal number that follows in the next two characters. In your example that is %2C
, which is the hexadecimal number for the comma. Unescaped that becomes asset=travel,car,house,business
% 表示转义字符。它是一个十六进制数,后跟在接下来的两个字符中。在您的示例中%2C
,它是逗号的十六进制数。无法逃脱的变成asset=travel,car,house,business
回答by Isaiah Turner
%2C is a comma and %20 is a space.
%2C 是逗号,%20 是空格。
回答by Merlin
there is quite a difference. both are hexadecimals, but %20 means a space and %2C means a comma.
有很大的不同。两者都是十六进制,但 %20 表示空格, %2C 表示逗号。
回答by user2023370
Let me paraphrase from the excellent answer here: %2C
is the ASCII keycode in hexadecimal for a comma; and %20
is the ASCII keycode for a space. You can see it in the table below under the relevant Hx
column. Also see http://www.asciitable.com.
让我从这里的优秀答案中转述:%2C
是逗号的十六进制 ASCII 键码;并且%20
是一个空间的ASCII键码。您可以在下表的相关Hx
列下看到它。另请参阅http://www.asciitable.com。
+----+-----+----+-----+----+-----+----+-----+
| Hx | Chr | Hx | Chr | Hx | Chr | Hx | Chr |
+----+-----+----+-----+----+-----+----+-----+
| 00 | NUL | 20 | SPC | 40 | @ | 60 | ` |
| 01 | SOH | 21 | ! | 41 | A | 61 | a |
| 02 | STX | 22 | " | 42 | B | 62 | b |
| 03 | ETX | 23 | # | 43 | C | 63 | c |
| 04 | EOT | 24 | $ | 44 | D | 64 | d |
| 05 | ENQ | 25 | % | 45 | E | 65 | e |
| 06 | ACK | 26 | & | 46 | F | 66 | f |
| 07 | BEL | 27 | ' | 47 | G | 67 | g |
| 08 | BS | 28 | ( | 48 | H | 68 | h |
| 09 | TAB | 29 | ) | 49 | I | 69 | i |
| 0A | LF | 2A | * | 4A | J | 6A | j |
| 0B | VT | 2B | + | 4B | K | 6B | k |
| 0C | FF | 2C | , | 4C | L | 6C | l |
| 0D | CR | 2D | - | 4D | M | 6D | m |
| 0E | SO | 2E | . | 4E | N | 6E | n |
| 0F | SI | 2F | / | 4F | O | 6F | o |
| 10 | DLE | 30 | 0 | 50 | P | 70 | p |
| 11 | DC1 | 31 | 1 | 51 | Q | 71 | q |
| 12 | DC2 | 32 | 2 | 52 | R | 72 | r |
| 13 | DC3 | 33 | 3 | 53 | S | 73 | s |
| 14 | DC4 | 34 | 4 | 54 | T | 74 | t |
| 15 | NAK | 35 | 5 | 55 | U | 75 | u |
| 16 | SYN | 36 | 6 | 56 | V | 76 | v |
| 17 | ETB | 37 | 7 | 57 | W | 77 | w |
| 18 | CAN | 38 | 8 | 58 | X | 78 | x |
| 19 | EM | 39 | 9 | 59 | Y | 79 | y |
| 1A | SUB | 3A | : | 5A | Z | 7A | z |
| 1B | ESC | 3B | ; | 5B | [ | 7B | { |
| 1C | FS | 3C | < | 5C | \ | 7C | | |
| 1D | GS | 3D | = | 5D | ] | 7D | } |
| 1E | RS | 3E | > | 5E | ^ | 7E | ~ |
| 1F | US | 3F | ? | 5F | _ | 7F | DEL |
+----+-----+----+-----+----+-----+----+-----+