Difference in URL decode/encode UTF-8 between Java and JS/AS3 (bug!?)

后端 未结 3 704
无人及你
无人及你 2021-01-06 00:50

I am having an issue URL decoding a UTF-8 string in Java that is encoded either with Javascript or Actionscript 3. I\'ve set up a test case as follows:

The string in

3条回答
  •  盖世英雄少女心
    2021-01-06 01:41

    Javascript is URL encoding your string using Latin-1 charset. Java is URL encoding it using UTF-8.

    The URL encoding is really just replacing the characters/bytes that it doesn't recognise. For example, even if you were to stick with ASCII characters, ( would be encoded as %28. You have the additional problem of character sets when you start using non-ASCII characters (any thing longer than 7 bits).

提交回复
热议问题