robert_gsfame Posted April 21, 2010 Share Posted April 21, 2010 I have created a function in which the value has been encoded, how can i decode the value? unescape???or there is another way Link to comment https://forums.phpfreaks.com/topic/199248-encode-decode/ Share on other sites More sharing options...
Mchl Posted April 21, 2010 Share Posted April 21, 2010 If you created encoding function, you should know how to decode it. Just do what encoding function does in reverse (unless it implements some assymetric algorithm, which I doubt). Link to comment https://forums.phpfreaks.com/topic/199248-encode-decode/#findComment-1045751 Share on other sites More sharing options...
robert_gsfame Posted April 21, 2010 Author Share Posted April 21, 2010 i have this in my html code onclick="test('$test1')" just let say $test1 ==>simple media@#$%^& has been encoded using urlencode so that i will have this Simple+Media%40%21%24%25%5E%26%2A% function test(x){ var test=unescape(x) alert('test') } using unescape will still leave the + sign, and when i use replace to change the sign with space, how come i still find the + sign??? Link to comment https://forums.phpfreaks.com/topic/199248-encode-decode/#findComment-1045760 Share on other sites More sharing options...
salathe Posted April 21, 2010 Share Posted April 21, 2010 Use the decodeURIComponent function. Link to comment https://forums.phpfreaks.com/topic/199248-encode-decode/#findComment-1045790 Share on other sites More sharing options...
robert_gsfame Posted April 21, 2010 Author Share Posted April 21, 2010 not working..... the plus + sign is still there replacing the " " Link to comment https://forums.phpfreaks.com/topic/199248-encode-decode/#findComment-1045817 Share on other sites More sharing options...
robert_gsfame Posted April 21, 2010 Author Share Posted April 21, 2010 i use replace , unescape, decodeURI everything cannot replace the + with space Link to comment https://forums.phpfreaks.com/topic/199248-encode-decode/#findComment-1045841 Share on other sites More sharing options...
robert_gsfame Posted April 21, 2010 Author Share Posted April 21, 2010 finally!!! var test=unescape(str.replace(/\+/g, " ")); Link to comment https://forums.phpfreaks.com/topic/199248-encode-decode/#findComment-1045850 Share on other sites More sharing options...
salathe Posted April 21, 2010 Share Posted April 21, 2010 Ahh, I totally misread the posts. Anyway, glad you got it sorted. Link to comment https://forums.phpfreaks.com/topic/199248-encode-decode/#findComment-1045914 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.