By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,693 Members | 1,230 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,693 IT Pros & Developers. It's quick & easy.

URI manipulation

P: n/a
Nak
Hi there,

When getting an URI sometimes it contains character combinations to
replace certain characters, such as "%20" for a space. Is there a function
in the .NET framework that converts these into their correct characters?
i.e.

"c:\my%20folder\my%20file.jpg"

to

"c:\my folder\my file.jpg"

Thanks in advance.

Nick.

--
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
"No matter. Whatever the outcome, you are changed."

Fergus - September 5th 2003
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
Nov 20 '05 #1
Share this Question
Share on Google+
13 Replies


P: n/a
Nak
I think decoding an URL might be the phrase that I am looking for. If I
need to write my own function to do this does anyone know where I can find
any reference to what the special characters are and what they should be
replaced for? Thanks again :-)

Nick.

--
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
"No matter. Whatever the outcome, you are changed."

Fergus - September 5th 2003
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
Nov 20 '05 #2

P: n/a
Cor
Nick,
This is from the document object model (mshtml)
URLUnencoded
Look for this on MSDN
As far as I understand you, does it exact what you ask, but are you using
mshtml
(Maybe you can do it with some JScript)
Cor
Nov 20 '05 #3

P: n/a
Hello,

"Nak" <a@a.com> schrieb:
But I get errors with that as when I use the ".location.
URLUnencoded" property I am getting "undefined"
returned. If I use URL I get the encoded URL but when
I use URLUnencoded it doesn't work. Is there no way of
decoding an URL within .NET?


Use 'document.URLUnencoded' instead.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #4

P: n/a
Hello,

"Jeff Molby" <JeffMolby@C_mc_st.n_t> schrieb:
I've never had to do it, so I'm not sure, but have you looked into the
System.URI and System.URIBuilder classes?


I have played around with both of the classes but I didn't find an easy way
to replace the encoded characters. If you find a solution, please let us
know.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #5

P: n/a
Nak
> I have played around with both of the classes but I didn't find an easy
way
to replace the encoded characters. If you find a solution, please let us
know.


All sorted now, I just have to keep the original passed URL because when it
is put into the URI object it encodes it again. Thanks for your help :-)

Nick.

--
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
"No matter. Whatever the outcome, you are changed."

Fergus - September 5th 2003
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
Nov 20 '05 #6

P: n/a
Nak
> Use 'document.URLUnencoded' instead.

Thanks Herfried :-)

Nick.

--
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
"No matter. Whatever the outcome, you are changed."

Fergus - September 5th 2003
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
Nov 20 '05 #7

P: n/a
Hello,

"Nak" <a@a.com> schrieb:
All sorted now, I just have to keep the original passed
URL because when it is put into the URI object it encodes
it again.


There is an overloaded constructor for the 'Uri' class that allows to
specify in the 2nd parameter that no encoding should be done. Nevertheless
I didn't find a way to remove the encoding.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #8

P: n/a
Hello,

"Nak" <a@a.com> schrieb:
Use 'document.URLUnencoded' instead.


Thanks Herfried :-)


I hope it helped. I searched for "URLUnencoded" in the MSDN libarary.
Maybe you can do that yourself in future.

;-)

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #9

P: n/a
Nak
> I hope it helped. I searched for "URLUnencoded" in the MSDN libarary.
Maybe you can do that yourself in future.


Thanks Herfried. I would request that you cut the sarcasm, for your
information I had that web page on the screen at the time I recieved your
suggestion, I was trying many permiations of accessing the same variables
with no luck, your suggestion had been the only one that I hadn't tried.

Believe it or not, I do try other places before I try here, so don't be so
rude Herfried, you should know better!

Nick.

--
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
"No matter. Whatever the outcome, you are changed."

Fergus - September 5th 2003
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
Nov 20 '05 #10

P: n/a
Hello,

"Nak" <a@a.com> schrieb:
I hope it helped. I searched for "URLUnencoded" in the
MSDN libarary. Maybe you can do that yourself in future.


Thanks Herfried. I would request that you cut the sarcasm,
for your information I had that web page on the screen at
the time I recieved your suggestion, I was trying many permiations
of accessing the same variables with no luck, your suggestion had
been the only one that I hadn't tried.

Believe it or not, I do try other places before I try here, so don't be so
rude Herfried, you should know better!


Sorry, it was only a "joke".

;-)

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #11

P: n/a
Nak
> Sorry, it was only a "joke".

Well hardy har! I was actually quite offended by that, but never mind. I'm
really appreciative of youe help Herfried, I know that you are a whole
wealth of knowledge and that you are miles ahead of myself, but you don't
need to rub it in with comments like that.

You spend hours and hours each day devoting your own time to people to help
them, and that is great, I spend hours and hours each day trying to program
my own applications, sometimes I miss something on a web site or have
problems understanding the jargon (you obviously don't have this problem),
but believe me, for every 1 question that I ask for myself in this newsgroup
I have already written many lines of code that I have found out myself! I
don't ask for help at every step believe me!, just the ones I am stuck on.

Nick.

--
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
"No matter. Whatever the outcome, you are changed."

Fergus - September 5th 2003
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
Nov 20 '05 #12

P: n/a
Hello,

"Nak" <a@a.com> schrieb;
Sorry, it was only a "joke".
Well hardy har! I was actually quite offended by that,
but never mind.


:-)
wealth of knowledge and that you are miles ahead of myself,
but you don't need to rub it in with comments like that.


Sorry...

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #13

P: n/a
Hi Nick,

NET Framework does offer such a function to decode URIs. The special
characters are encoded with ASCII. If you¡¯re developing a web form
application, you can try to use java script to decode it.

If anything is unclear, please feel free to reply to the post.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
--------------------
| From: "Nak" <a@a.com>
| Subject: URI manipulation
| Date: Mon, 15 Sep 2003 12:37:44 +0100
| Lines: 25
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <eg**************@TK2MSFTNGP11.phx.gbl>
| Newsgroups: microsoft.public.dotnet.languages.vb
| NNTP-Posting-Host: dsl213-218-224-160.as15444.net 213.218.224.160
| Path:
cpmsftngxa07.phx.gbl!cpmsftngxa10.phx.gbl!cpmsftng xa06.phx.gbl!TK2MSFTNGP08.
phx.gbl!TK2MSFTNGP11.phx.gbl
| Xref: cpmsftngxa07.phx.gbl microsoft.public.dotnet.languages.vb:137295
| X-Tomcat-NG: microsoft.public.dotnet.languages.vb
|
| Hi there,
|
| When getting an URI sometimes it contains character combinations to
| replace certain characters, such as "%20" for a space. Is there a
function
| in the .NET framework that converts these into their correct characters?
| i.e.
|
| "c:\my%20folder\my%20file.jpg"
|
| to
|
| "c:\my folder\my file.jpg"
|
| Thanks in advance.
|
| Nick.
|
| --
|
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
| "No matter. Whatever the outcome, you are changed."
|
| Fergus - September 5th 2003
|
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
|
|
|

Nov 20 '05 #14

This discussion thread is closed

Replies have been disabled for this discussion.