Urldecode
G'day all, I'm receiving a column from a database that is an encoded URL request string. We've been using a SQL Server function to decode this URL but recently the string coming in has 4000+ parameters which is taking a while to parse through the function
so I'm looking to see how a SSIS script component can handle the equivalent. However, when I try to include the System.Web namespace (using C#), it doesn't give me the option to choose subpackages (either Server or HttpUtility, not sure which will be the appropriate
package), any idea how I get this package available? Do I have to have a HTTP connection manager to make these available or have I missed something?
TIA
Hi TIA,
According to your description, you are trying to use Server or HttpUtility class to decode an encoded URL request string. While after adding System.Web namespace, you still couldn’t use Server or HttpUtility class.
From the
document, we can know that the HttpUtility class is included in System.Web.dll assembly System.Web namespace. Based on my research, it seems that the System.Web.dll assembly is not referenced by default in new projects.
So to fix this issue, please right-click References in the Solution Explorer and choose Add Reference, then select System.Web in .NET pane. Then we can use HttpUtility.UrlDecode or HttpServerUtility.UrlDecode method to decode the URL string.
If there are any other questions, please feel free to ask.
Thanks,
Katherine Xiong
Katherine Xiong
TechNet Community Support
Similar Messages
-
Problem with URLDecoder.decode(s, enc)
Hi!
I'm having problems with the URLDecoder.decode(s, enc) method... When I send a string, encoded with the Javascript escape() function, to the server side of my application, I get a problem decoding it using this:
myString = URLDecoder.decode(myString, "iso-8859-1");It gives me this error: URLDecoder: Illegal hex characters in escape (%) pattern - For input string: "u2"
My html defines the encoding as follows:
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />The string being submitted contains a special apostrophe ( ' ) copy/pasted from MS Word wich then translates it as %u2019 (what's that??? Unicode???).
Can anyone tell me what is happening? How can I encode / decode this properly?I'm having exactly the same issue.
Did you solved the problem?
Regards,
Gabriel -
URLDecoder / URLEncoder don't like non-ASCII, even with UTF-8 explicit
Here's my code:
import java.net.*;
import java.io.*;
public class Decoder
public static void main(String[] args)
if (args.length != 1) {
System.err.println("Usage: Decoder UTF-8-URL-encoded-string");
System.exit(1);
String sampleString = "auflerhalb";
try {
for (int k = 0; k < args[0].length(); k++) {
System.out.println("Char is " + Character.codePointAt(args[0], k));
System.out.println();
String queryText = URLDecoder.decode(args[0], "UTF-8");
for (int k = 0; k < queryText.length(); k++) {
System.out.println("Char is " + Character.codePointAt(queryText, k));
String newText = URLEncoder.encode(queryText, "UTF-8");
System.out.println(newText);
System.out.println();
for (int k = 0; k < sampleString.length(); k++) {
System.out.println("Char is " + Character.codePointAt(sampleString, k));
System.out.println(URLEncoder.encode(sampleString, "UTF-8"));
catch ( UnsupportedEncodingException e ) {
System.err.println("Couldn't decode querytext as UTF-8");
System.exit(0);
}The problem I'm encountering is that characters such as the German S-like character aren't being decoded correctly, or encoded correctly. When I run this file, on Linux, MacOS X or Solaris 10, I get this:
% java -version
java version "1.5.0_07"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_07-b03)
Java HotSpot(TM) 64-Bit Server VM (build 1.5.0_07-b03, mixed mode)
% java -cp . Decoder "au%DFerhalb"
Char is 97
Char is 117
Char is 37
Char is 68
Char is 70
Char is 101
Char is 114
Char is 104
Char is 97
Char is 108
Char is 98
Char is 97
Char is 117
Char is 65533
Char is 101
Char is 114
Char is 104
Char is 97
Char is 108
Char is 98
au%EF%BF%BDerhalb
Char is 97
Char is 117
Char is 223
Char is 101
Char is 114
Char is 104
Char is 97
Char is 108
Char is 98
au%C3%9Ferhalb
The decimal code point of the German S is 223; the hex code point is DF. Yet the decoder completely mangles the string containing %DF, and the internal string, which clearly has the right decimal code point, is mangled by the encoder; C3 9F has absolutely nothing to do with 223.
I can't figure out for the life of me what I'm doing wrong. I've taken a look at the source code for URLDecoder.java, and it really appears that it's broken; it decodes hex sequences into a byte array, but Java bytes are signed, between -128 and 128. Could this be what's going on? Hex code points up to 127 work fine; above it don't work at all. Try my function with %7E instead of %DF, and then with %81.
Can this really be broken?
Thanks in advance -
Sam Bayer
The MITRE Corporation
[email protected]The decimal code point of the German S is 223; the hex code point is DF.
Yet the decoder completely mangles the string containing %DF, and the
internal string, which clearly has the right decimal code point, is mangled
by the encoder; C3 9F has absolutely nothing to do with 223.I don't think you understand what's going on. I haven't checked the Unicode table but let's assume that hex-DF is the Unicode code point for that character. That means it's in the range which UTF-8 will encode in two bytes. I haven't run it through the algorithm but it's quite likely that the result would be C3 9F, since that's what happened when you did it. It would certainly be two bytes and not one, contrary to what you expect. -
Could someone PLEASE help me on the syntax for URLdecoding?
In the code below, I want to URLdecode the "description" that
I am displaying in the textfield.Can you give us a little more information about the
"description" data that you're trying to display. You could try the
top level function un_escape() (remove the underscore – the
word is censored on this forum).
myHolder.myTextField.text = un_escape(e.target.description);
//again, remove the underscore
TS -
Problems with urldecoding of %
hi,
in my servlet's post method i set
request_.setCharacterEncoding("UTF-8");
and then i gonna urldecode the parameters with
String value = request_.getParameter(PARAM);
String decValue = URLDecoder.decode(value.trim(), "UTF-8");
everything seems to work fine (even for some chinese utf-8 codes).
the only problem i got now is the "%".
i know that the urlencoded value is %25. however when i read out the
parameter there is only the % left (before i urldecode it). i don't quite
understand why this happens. i thought i should get the %25 before i
decode it. i am a bit puzzled because it works with other unicodes.
anybody out there who knows what happens?
thanx.You don't need to decode it, the server already does it for you. Just call setCharacterEncoding and getParameter and you're done.
-
ASCII equivalent of CF's URLDecode?
Hello, everyone.
Even though I've been working with CF for over a decade, this is going to sound like a total n00b question. I'm just drawing a blank, right now. Google isn't much help.
Is there an ASCII equivalent of URLDecode??
Where I work, everything that is inserted into a database goes through a filter that changes certain characters to their ASCII equivalent (ie, the less than "<" is altered to "<"). For displaying the data, I need to revert the < back to < for formatting (there are <br /> in place of line breaks, in the data.)
If not, I suppose I should check cflib to see if there is a UDF. Hmm..
Respectfully,
^_^Well, first, that's not ASCII encoding, that's HTML Entity Encoding.
Second, no. There is not a built-in function for decoding HTML entities. The purpose of the function is to use it when displaying output to the screen, not to use it before sotring data for later use.
Obviously that doesn't help since you already have a system that encodes before putting data into the DB. So you need a way to decode it.
If you are using CF8 or CF9, with all of the security hotfixes installed, or you are using CF10, then you'll have ESAPI available to you via Java integration. ESAPI is a security tool from OWASP with built-in encoders and decoders. You can use those. Here is how.
<cfoutput>
<cfset string = "<hi>" />
<cfset list = createObject("java", "java.util.ArrayList") />
<cfset htmlCodec = createObject("java", "org.owasp.esapi.codecs.HTMLEntityCodec") />
<cfset list.add(htmlCodec) />
<cfset encoder = createObject("java", "org.owasp.esapi.reference.DefaultEncoder").init(list) />
#string#
<br />
#encoder.decodeForHTML(string)#
</cfoutput>
Hope that helps. -
URLEncodedFormat and URLdecode
I am passing some dynamic variables through the URL as
name/value pairs and before doing so I'll put the value variable
through the URLEncodedFormat function to take care of special
characters. However, when I get to the other page I noticed that
when I use that variable (I'm guessing it is now in the URL scope)
in a form field, or even just output it to the page, it displays
properly. That is it seems to automatically decode the value of the
name/value pair without using the URLdecode function. So is
URLdecode necessary?It's automatically decode the value, but to be safe use
URLDecode().
p.sim -
greetings,
I have a form on my web site that will remember you information from the last time you filled it out.
Upon submitting the form, I store the values in a cookie using javascript. When you load the form the next time, I use JSP to read in the cookie, parse out the appropriate values and set them to the value attributes of the various form elements.
This all works fine in IE but for some reason netscape is returning these values URLencoded, I think.
For email address, I am getting:
davep%40example.com
instead of
[email protected]
I tried to apply the urlDecode method to the string as such:
emailVal = urlDecode(emailVal);
but got the following error:
/var/tomcat4/work/Standalone/localhost/raindance/content/trybuy/signup_services_jsp.java:145: cannot resolve symbol
symbol : method urlDecode (java.lang.String)
location: class org.apache.jsp.signup_services_jsp
emailVal = urlDecode(emailVal);
What am I doing wrong?check java.net.URLDecoder for syntax.
-
URLEncodedFormat() / URLDecode
I found the live docs version of these 2 functions, but does
anyone know a
place to find a easier explanation on how to use these?
I know to use the URLEncodedFormat() you would use:
<cflocation
url="page.cfm?var=#URLEncodedFormat('Form.variabletosend#')">
But I am not sure how to 'decode' it on another page to use
it as a variable
on another page.
Thanks
Wally Kolcz
Developer / Support1. You need to use URLEncodedFormat() for every value you
pass, not for the entire query string.
2. You cannot arbitrary apply URLDecode() in your
application, if you receive values, as Cold Fusion variables.
Consider the following example:
<cfset mvar="C/C++">
<a
href="test.cfm?mvar=<cfoutput>#URLEncodedFormat(mvar)#<cfoutput>">Click
Me</a>
Then, on test.cfm page:
<cfoutput>
#mvar# #URLDecode(mvar)#
</cfoutput>
You will see that values are different and the second one is
not that you passed.... -
Hi,
We encounter some errors on JavaScript and ColdFusion.navigate.
We use
ColdFusion.navigate('cfc/control.cfc?method=checkName&name='+encodeURIComponent(document.g etElementById('name').value),'addName,addName);
In control.cfc, we use this statement to get the original name <cfset newName = URLDecode(name)>.
However, it encounters error and cannot show the result. When I add ?cfdebug to url, it cannot show me the error.
For example, user inputs "A+C" (the encoded code is "A%2BC", URLDecode cannot return "A+C", it returns "A C".
When if user inputs "A C" or some Chinese words, it runs correctly.
Can anyone help me to solve the problem?somewhat similar problem solved in the below thread:
Web UI does not work after deployment of BBPCRM SP for CRM 7
P.N.: the above thread is not related to XI/PI......giving for your reference -
URLDecode vs decodeURIComponent
Hi All,
I am working on windows 2000 server, cfmx 6.1
I have to encod an url parameter, i do that with the
javascript function "encodeURIComponent()" because sometimes the
sign "+" is in the string.
That works fine.
The problem is with latin characters non ascii:
myString = "Acteur / Métier";
url = "mysite?maVar="+encodeURIComponent(myString);
Server Side:
I have tried
<cfset theVar = url.maVar>
<cfset theVar = URLDecode(url.maVar)>
but each time the result is the same theVar = "Acteur /
Métier"
Does any one know how to solv this?Thanks a lot.
Like i have to encode with javascript, i have found a
function to do that
http://ostermiller.org/calc/encode.html
and Server Side i use
<cfset maVar = ToBinary(url.maVar)>
and
<cfset maVar = ToString(variables.maVar)>
and all is OK. -
I don't know if I have typed them right!
urldecode or urlencode, how and when should they be used in JSP?I don't know if I have typed them right!Maybe! Maybe not!
urldecode or urlencode, how and when should they be
used in JSP?What are these?!? Methods? Of which class? Where are the API docs located? -
URLDecoder behaviour in Solaris
I run following piece of code in solaris and windows env. and get different results. Pls can someone give idea what is wrong in my solaris setup.
//---------CODE START--------------
public class TestEncBasic
public static void main(String arg[])
String strURL = "%DC" ;
String strTest = java.net.URLDecoder.decode(strURL);
for (int i = 0 ; i < strTest.length() ; i++)
System.out.println("char =" + strTest.charAt(i) + " int =" + (int)strTest.charAt(i) ) ;
System.out.println("System encoding =" + System.getProperty("file.encoding"));
// ---------CODE END----------
Output in Solaris :
char =? int =65533
System encoding =646
java full version "1.3.1_06-b01"
OS : SunOS amazon 5.8 Generic_108528-03 sun4u sparc SUNW,Ultra-4
Output in Windows2000 :
char =▄ int =220
System encoding =Cp1252
java full version "1.3.1_04-b02"
Output in Linux :
char =� int =220
System encoding =ISO-8859-15
java full version "Blackdown-1.3.1-FCS"
OS: Linux conjurer 2.4.18-3 #1 Thu Apr 18 07:37:53 EDT 2002 i686 unknownThe URLDecoder method you used uses the default charset encoding for the system you are on. You should use the method where you can specify the charset. a good charset to use is UTF-8 since it is a charset that java supports.
//---------CODE START--------------
public class TestEncBasic
public static void main(String arg[])
String strURL = "%DC" ;
String strTest = java.net.URLDecoder.decode(strURL, "UTF-8");
for (int i = 0 ; i < strTest.length() ; i++)
System.out.println("char =" + strTest.charAt(i) + " int =" + (int)strTest.charAt(i) ) ;
System.out.println("System encoding =" + System.getProperty("file.encoding"));
// ---------CODE END----------
This code should return the same answer for all systems -
Sax XML Parser? URLDecoder.decode bad in applet? Explorer Browser jvm?
Ok, here it goes folks, I have a serious problem with Explorers jvm, I'm developing using jdk 1.3.1 to write swing applets, in anyevent little functions that I use will not work with Explorers Browser, for example, the Explorer JVM understands the Vector addElement function, but not the Vector add function? Also, It doesn't recognize the HashMap class? Ok, is there anyway to control the JVM used with Explorer? Ok, but here goes my real question?
I am writing an applet/servlet that interfaces with an oracle database. The data is returned in the form of xml. We are using the Sax XML parser interface. The parser code previously in the servlet(server side) and worked fine, but I've now moved the parsing code to the applet side, however, it seems to not want to work on the applet side. It simply hangs? I think it's a jvm issue, I've been getting many hangs with seemingly standard classes and methods, such as URLDecoder.decode(). Anyone else run into this problem using the Sax XML Parser, I have no idea what classes in the SAX Parser could be giving us a problems, or if that is even my issue. Anyone else using SAX XML parsing in an applet with Explorer 5.5. or 5.0, please let me know, if you've had issues?
Sorry, to be so long winded, and not explaining the problem very well.First, get Sun's Java Plug-in from http://java.sun.com/products/plugin/index-1.4.html
and read up on how to make your browser use it instead. -
URLDecoder works incorrectly in chinese GBK char with Internet Explorer
The chinese string "�u" should be normally encoded as "%AC%75" in GBK, but Internet Explorer encode it as "%ACu" according to '%75'=='u'.
When URLDecoder encounters url encoded by IE, it will decode '%AC' using gbk charset, and then append 'u' to the result above. So the final result is '?u', it cause a lot of problem to our application.
for a simple workaround, we use the code below instead of simply call URLDecoder.
new String(URLDecoder.decode("%ACu", "iso8859-1").getBytes("iso8859-1"), "gbk")
Is it a bug of URLDecoder?According to your own description it is a bug in IE.
Maybe you are looking for
-
Error in customized smartform for goods recipt
Hi experts I have created a customized smartform for goods recipt . I have used form entry_we01 inside my zprogram and basically fetching the material document no from NAST-objky The problem is when i assign my program in TXN NACE it prevents th
-
ITunes stops working when importing CDs
I insert a CD, try to import the tracks. Itunes starts to work on the first track. Just as import of the first track reaches its conclusion a message pops up to say that iTunes has stopped working. "A problem caused the program to stop working correc
-
[SOLVED]Applications left after uninstalling wine
I've completely uninstalled wine without uninstalling the applications I was running through it. Now their entries were left in the Activities menu (gnome shell). How do I remove them? Last edited by bogdan2011 (2012-02-04 09:00:04)
-
Incorrect autofill email in safari
Hi This has been driving me mad, I've checked google and the forum and find several references to autofill drawing the autofill email details from contacts, however I've checked that and I can't find the problem. The issue is with my wife's email add
-
2.16GHz Intel Core 2 Duo Upgrade?
Hello all, I have an older macbook pro, I think it's about three years old? It's the non unibody (all silver) version. I've been looking into upgrading to Lion, but I'm not sure if my computer is compatible. My processor is a 2.16GHz Intel Core 2 Duo