Why encodeURIComponent Chinese twice?

when calling the wx.reDirectTo of the H5 page in Mini Program, the url contains Chinese. Why is it necessary to encode the Chinese in url twice to be valid, otherwise the link cannot be skipped

Apr.18,2021

this is mainly to parse the % symbol in URL. For example, encodeURIComponent ('I') will become "% E6% 88% 91", and then the second parse will change all% to% 25, to "% 25E6%2588%2591"

.

as for the significance of doing this, I guess it is to be compatible with all coding standards, because if decode is based on "% 25E6%2588%2591", the string can be restored to "% E6% 88% 91", while if "% E6% 88% 91" is restored directly, the strings restored by different coding standards will be inconsistent and garbled will occur.

Menu