15

The java application that I am developing right now is posting an url and some part of the url is like this:

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.

anathema
  • 947
  • 2
  • 15
  • 27

5 Answers5

20

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

Ghostkeeper
  • 2,830
  • 1
  • 15
  • 27
  • 1
    Stole my thunder in 3 seconds exactly :p – Isaiah Turner Feb 27 '14 at 01:19
  • 1
    that was fast :) I didn't noticed the capital C, well thank you :) – anathema Feb 27 '14 at 01:23
  • %-encoding can be used for binary or character data. Newer standards specify UTF-8 as the character encoding for text so the bytes are for the text encoded using UTF-8. That why %2C represents [Unicode Character 'COMMA' (U+002C)](https://www.fileformat.info/info/unicode/char/002c/index.htm). – Tom Blodget Nov 23 '18 at 15:46
7

%2C is a comma and %20 is a space.

Isaiah Turner
  • 2,574
  • 1
  • 22
  • 35
0

there is quite a difference. both are hexadecimals, but %20 means a space and %2C means a comma.

Merlin
  • 179
  • 4
  • 11
0

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.

        +----+-----+----+-----+----+-----+----+-----+
        | 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 |
        +----+-----+----+-----+----+-----+----+-----+
user2023370
  • 10,488
  • 6
  • 50
  • 83
  • Your mention of ASCII (vs UTF-8) doesn't jive with RFC 3986 and the HTML 5 standard. Previously, the character encoding was unspecified. Now, for HTML, it is UTF-8. – Tom Blodget Nov 23 '18 at 15:50
0

%20 for space (space character) and %2C for , (comma character) are in Hex values.

Using the link below you can convert Hex values to Ascii. Try these values and see the result:

https://www.rapidtables.com/convert/number/hex-to-ascii.html

Alireza
  • 100,211
  • 27
  • 269
  • 172