简体   繁体   中英

javascript encodeURI() output

According to MDN , The 'encodeURI()' function:

replacing each instance of certain characters by one, two, three, or four escape sequences representing the UTF-8 encoding of the character

However, when invoking encodeURI('\‚') (in Chrome) Im getting %C2%81 as output.

I expected to get %82 or %00%82 . What does the %C2 mean?

The '0082' in '\‚' is the Unicode code point, not the UTF-8 bytes representation. UTF-8 maps u+0082 code point to two bytes: C2+81

Unicode to UTF-8 mapping table

Decoding %C2 at http://www.albionresearch.com/misc/urlencode.php leads to Â

When dealing with German texts and ISO 8859-15 / ISO 8859-1 vs. UTF-8 I often ran into the à character. The characters are quite close to each other. May this also be an encoding problem?

Maybe HTML encoding issues - "Â" character showing up instead of " " helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM