Question about urlencode

When using urlencode, the soemtimes space is encoded in +; is it sometimes encoded in% 20? I am wondering which one is the standard in HTML?

+3
source share
5 answers

None. Request encoding is part of the URI / URN standard, and depends entirely on the server how it wants to get the result. Some use% coding, so they can figure out a safe place (readability doesn't matter), some use +, some use - (i.e. stack overflow).

The reason for the encoding is simple, URIs / URNs do not allow spaces (and other special characters). However, the standard does not specify how this should be done.

+3
source

URI Percent- . URI, %20.

, HTML 4 /x -www-form-urlencoded , Percent- , + %20.

PHP URI:

+1

urlencode +, rawurlencode %20.

urlencode

"RFC 3986" (. rawurlencode()) , (+).

rawurlencode

, -- , -_. ~, (%), . , "RFC 3986 URL-, URL- (, ).

+1

'+' (RFC 3986) URI. URI 2 : URL URN. "http:" - URL-, RFC 3986 http. "?" URI, URL- http. , "+" . ( %20) URI ( ).

, . (+) %20?

+1

There is no HTML urlencode, so it is not defined.

It is a matter of designing and implementing one in which spaces is transformed.

Spaces are not URI-valid, so they need to be converted. %20- A valid URI encoding for spaces. +is a replacement space for better readability.

0
source

Source: https://habr.com/ru/post/1793258/


All Articles