decodeuricomponent

NodeJS decodeURIComponent not working properly

牧云@^-^@ 提交于 2020-01-01 11:58:50
问题 When I tryed to decode the string below in nodeJS using decodeURLCompnent: var decoded = decodeURI('Ulysses%20Guimar%C3%A3es%20-%20lado%20par'); console.log(decoded); I got Ulysses Guimarães - lado par Instead of Avenida Ulysses Guimarães - lado par But when I use the same code on the client side (browser) I can get the right char 'ã'. Is there a way to convert from ã to ã in a Node script? 回答1: I cannot reproduce it in 0.10 or 0.11 versions of node. You can convert first to second using

understanding how decodeURI works

谁说胖子不能爱 提交于 2019-12-25 02:12:05
问题 I am trying to get the decoded value for the string. I notice that decodeURI (i am not using unescape because i read somewhere that its deprecated) works when i do a document.write(), but the alert still shows the non-decoded value. var uri = "Hello's "; var dec = decodeURI(uri); alert(dec); document.write(dec); I finally used the below code and things worked; var strName = $('<div/>').html("Hello's").text(); but still wondering why the original code doesn't work? It seems to be a pretty

Why does decodeURIComponent('%') lock up my browser?

痞子三分冷 提交于 2019-12-18 20:01:11
问题 I was just testing something with AJAX and I found that on success if I alert alert(decodeURI('%')); or alert(encodeURIComponent('%')); the browser errors out with the following code. $.ajax({ type: "POST", url: "some.php", data: "", success: function(html){ alert(decodeURIComponent('%')); // alert(decodeURI('%')); } }); If I use any other string it works just fine. Is it something that I missed? 回答1: Chrome barfs when trying from the console. It gives an URIError: URI malformed. The % is an

Lua - decodeURI (luvit)

早过忘川 提交于 2019-12-07 03:26:45
问题 I would like to use decodeURI or decodeURIComponent as in JavaScript in my Lua (Luvit) project. JavaScript: decodeURI('%D0%BF%D1%80%D0%B8%D0%B2%D0%B5%D1%82') // result: привет Luvit: require('querystring').urldecode('%D0%BF%D1%80%D0%B8%D0%B2%D0%B5%D1%82') -- result: '%D0%BF%D1%80%D0%B8%D0%B2%D0%B5%D1%82' 回答1: This is trivial to do yourself in Lua if you understand the URI percent-encoded format. Each %XX substring represents UTF-8 data encoded with a % prefix and a hexadecimal octet. local

NodeJS decodeURIComponent not working properly

家住魔仙堡 提交于 2019-12-04 09:28:18
When I tryed to decode the string below in nodeJS using decodeURLCompnent: var decoded = decodeURI('Ulysses%20Guimar%C3%A3es%20-%20lado%20par'); console.log(decoded); I got Ulysses Guimarães - lado par Instead of Avenida Ulysses Guimarães - lado par But when I use the same code on the client side (browser) I can get the right char 'ã'. Is there a way to convert from ã to ã in a Node script? I cannot reproduce it in 0.10 or 0.11 versions of node. You can convert first to second using new Buffer('Ulysses Guimarães - lado par', 'binary').toString('utf8') , but it's a workaround, not a solution

Javascript decodeURI(Component) malformed uri exception

天涯浪子 提交于 2019-12-03 07:27:48
问题 I entered the following in Chrome's console: decodeURIComponent('a%AFc'); Instead of resulting to a0xAFc , it caused a URIError exception (malformed uri). I've heard several excuses why this may be possible, but what I don't understand is why ? The decodeURIComponent() function in particular is supposed to decode data, not verify the URI. Wikipedia: Percent Encoding RFC3986: URI Generic Syntax (2005) 回答1: %AF is not a character on his own but part of Unicode sequence (MACRON - %C2%AF). %AF

Javascript decodeURI(Component) malformed uri exception

随声附和 提交于 2019-12-02 20:09:30
I entered the following in Chrome's console: decodeURIComponent('a%AFc'); Instead of resulting to a0xAFc , it caused a URIError exception (malformed uri). I've heard several excuses why this may be possible, but what I don't understand is why ? The decodeURIComponent() function in particular is supposed to decode data, not verify the URI. Wikipedia: Percent Encoding RFC3986: URI Generic Syntax (2005) %AF is not a character on his own but part of Unicode sequence ( MACRON - %C2%AF ). %AF wasn't produced by encodeURIComponent but something like escape , so it can be decoded by unescape . What