URI manipulation

  • Thread starter Thread starter Nak
  • Start date Start date
N

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
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
 
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
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
 
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
 
Hello,

Nak said:
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.
 
Hello,

Jeff Molby said:
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.
 
Use 'document.URLUnencoded' instead.

Thanks Herfried :-)

Nick.

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

Fergus - September 5th 2003
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
 
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
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
 
Hello,

Nak said:
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.
 
Hello,

Nak said:
Thanks Herfried :-)

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

;-)
 
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
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
 
Hello,

Nak said:
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".

;-)
 
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
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
 
Hello,

Nak said:
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...
 
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" <[email protected]>
| 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: <[email protected]>
| 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!cpmsftngxa06.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
|
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
|
|
|
 
Back
Top