473,626 Members | 3,320 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Server.URLEncod e diffrences in asp and vb.net

Trying to urlencode this string:

»ÁÏŒ*˜ ªŒ›h^aYh

in vb.net (using either HttpUtility.Url Encode(strEncry pted, encoding.UTF8)
orServer.UrlEnc ode) I get:
%c2%90%c2%bb%c3 %81%c3%8f%7f%c5 %92%c5%a0%cb%9c %c2%aa%c5%92%c2 %9d%e2%80%bah%5 eaYh

in ASP script (using Server.URLEncod e) I get:
%90%BB%C1%CF%7F %8C%8A%98%AA%8C %9D%9Bh%5EaYh

Any idea why?

Thanks,
Mark

Feb 1 '06 #1
9 4495
Well, This ended up working:
System.Text.Enc oding.UTF8.GetS tring(Convert.F romBase64String (strEncrypted))

Still odd that you have to jump though those hoops to get it to do what ASP
does.

Any insight would be appreciated.

Thanks,
Mark

"Mark_Raref y" wrote:
Trying to urlencode this string:

»ÁÏŒ*˜ ªŒ›h^aYh

in vb.net (using either HttpUtility.Url Encode(strEncry pted, encoding.UTF8)
orServer.UrlEnc ode) I get:
%c2%90%c2%bb%c3 %81%c3%8f%7f%c5 %92%c5%a0%cb%9c %c2%aa%c5%92%c2 %9d%e2%80%bah%5 eaYh

in ASP script (using Server.URLEncod e) I get:
%90%BB%C1%CF%7F %8C%8A%98%AA%8C %9D%9Bh%5EaYh

Any idea why?

Thanks,
Mark

Feb 1 '06 #2
Hello Mark,
Trying to urlencode this string:

h^a Yh
Hm... ;-)
in vb.net (using either HttpUtility.Url Encode(strEncry pted,
encoding.UTF8) orServer.UrlEnc ode) I get:
%c2%90%c2%bb%c3 %81%c3%8f%7f%c5 %92%c5%a0%cb%9c %c2%aa%c5%92%c2 %9d%e2%80%
bah%5eaYh

in ASP script (using Server.URLEncod e) I get:
%90%BB%C1%CF%7F %8C%8A%98%AA%8C %9D%9Bh%5EaYh
Any idea why?


ASP uses a different character encoding -- that's not UTF-8, but some 8 bit
encoding like ISO Latin 1 or Windos-1252.

Cheers,
--
Joerg Jooss
ne********@joer gjooss.de
Feb 1 '06 #3
Spoke to soon on that. Was looking at the result of the other page. I did
find a long right up that seems to be on the right track.

http://groups.google.com/group/micro...&start=0&num=3
"Mark_Raref y" wrote:
Well, This ended up working:
System.Text.Enc oding.UTF8.GetS tring(Convert.F romBase64String (strEncrypted))

Still odd that you have to jump though those hoops to get it to do what ASP
does.

Any insight would be appreciated.

Thanks,
Mark

"Mark_Raref y" wrote:
Trying to urlencode this string:

»ÁÏŒ*˜ ªŒ›h^aYh

in vb.net (using either HttpUtility.Url Encode(strEncry pted, encoding.UTF8)
orServer.UrlEnc ode) I get:
%c2%90%c2%bb%c3 %81%c3%8f%7f%c5 %92%c5%a0%cb%9c %c2%aa%c5%92%c2 %9d%e2%80%bah%5 eaYh

in ASP script (using Server.URLEncod e) I get:
%90%BB%C1%CF%7F %8C%8A%98%AA%8C %9D%9Bh%5EaYh

Any idea why?

Thanks,
Mark

Feb 1 '06 #4
Thanks for the reply.

When I tell ASP to force encoding as so:
Session.CodePag e = 65001
Response.CharSe t = "utf-8"

I get a totally diffrent result then the previous 2

I looked for the two encoding methods you mentioned in System.Text.Enc oding
but don't see them as options. I will google them and see what I can find.

Mark
"Joerg Jooss" wrote:
Hello Mark,
Trying to urlencode this string:

»ÁÏŒ*˜ ªŒ›h^aYh


Hm... ;-)
in vb.net (using either HttpUtility.Url Encode(strEncry pted,
encoding.UTF8) orServer.UrlEnc ode) I get:
%c2%90%c2%bb%c3 %81%c3%8f%7f%c5 %92%c5%a0%cb%9c %c2%aa%c5%92%c2 %9d%e2%80%
bah%5eaYh

in ASP script (using Server.URLEncod e) I get:
%90%BB%C1%CF%7F %8C%8A%98%AA%8C %9D%9Bh%5EaYh
Any idea why?


ASP uses a different character encoding -- that's not UTF-8, but some 8 bit
encoding like ISO Latin 1 or Windos-1252.

Cheers,
--
Joerg Jooss
ne********@joer gjooss.de

Feb 1 '06 #5
That did the trick. I couldn't find anything to do the conversion so I
wipped up this:
Public Function ASPURLEncode(By Val StringToEncode As String) As String

Dim TempAns As New StringBuilder
Dim CurChr As Integer = 1
Do Until CurChr - 1 = Len(StringToEnc ode)
Select Case Asc(Mid(StringT oEncode, CurChr, 1))
Case 48 To 57, 65 To 90, 97 To 122
TempAns.Append( Mid(StringToEnc ode, CurChr, 1))
Case 32
TempAns.Append( "%" & Hex(32))
Case Else
TempAns.Append( "%")
TempAns.Append( Hex(Asc(Mid(Str ingToEncode, CurChr, 1))))
End Select
CurChr = CurChr + 1
Loop
ASPURLEncode = TempAns.ToStrin g
End Function

And now I have a match.

Thanks for your help.

Mark

"Joerg Jooss" wrote:
Hello Mark,
Trying to urlencode this string:

»ÁÏŒ*˜ ªŒ›h^aYh


Hm... ;-)
in vb.net (using either HttpUtility.Url Encode(strEncry pted,
encoding.UTF8) orServer.UrlEnc ode) I get:
%c2%90%c2%bb%c3 %81%c3%8f%7f%c5 %92%c5%a0%cb%9c %c2%aa%c5%92%c2 %9d%e2%80%
bah%5eaYh

in ASP script (using Server.URLEncod e) I get:
%90%BB%C1%CF%7F %8C%8A%98%AA%8C %9D%9Bh%5EaYh
Any idea why?


ASP uses a different character encoding -- that's not UTF-8, but some 8 bit
encoding like ISO Latin 1 or Windos-1252.

Cheers,
--
Joerg Jooss
ne********@joer gjooss.de

Feb 1 '06 #6
Hello Mark,
Thanks for the reply.

When I tell ASP to force encoding as so:
Session.CodePag e = 65001
Response.CharSe t = "utf-8"
I get a totally diffrent result then the previous 2
I'm no old school ASP guy, but I'd guess that none of these properties affect
URL encoding performed by ASP.
I looked for the two encoding methods you mentioned in
System.Text.Enc oding but don't see them as options. I will google
them and see what I can find.


In ASP.NET, you can use System.Web.Http Utility.UrlEnco de(String, Encoding)
to URL encode a string using any System.Text.Enc oding.

Cheers,
--
Joerg Jooss
ne********@joer gjooss.de
Feb 1 '06 #7
I wrote that function but if I can, I would rather do it within the framework
..

"ISO Latin 1" isn't an option in system.text.enc oding.

Is there some other encoding method in the framework?

Thanks,
Mark

"Joerg Jooss" wrote:
Hello Mark,
Thanks for the reply.

When I tell ASP to force encoding as so:
Session.CodePag e = 65001
Response.CharSe t = "utf-8"
I get a totally diffrent result then the previous 2


I'm no old school ASP guy, but I'd guess that none of these properties affect
URL encoding performed by ASP.
I looked for the two encoding methods you mentioned in
System.Text.Enc oding but don't see them as options. I will google
them and see what I can find.


In ASP.NET, you can use System.Web.Http Utility.UrlEnco de(String, Encoding)
to URL encode a string using any System.Text.Enc oding.

Cheers,
--
Joerg Jooss
ne********@joer gjooss.de

Feb 1 '06 #8
Hello Mark,
I wrote that function but if I can, I would rather do it within the
framework .

"ISO Latin 1" isn't an option in system.text.enc oding.

Is there some other encoding method in the framework?


ISO Latin 1 is an alias for ISO-8859-1. You can create an instance either
by name

Encoding latin1 = Encoding.GetEnc oding("ISO-8859-1");

or by its Windows code page number

Encoding latin1 = Encoding.GetEnc oding(28591);

Cheers,
--
Joerg Jooss
ne********@joer gjooss.de
Feb 1 '06 #9
Hello Joerg,

Awesome, Windows-1252 did the trick.

Thanks for your help,
Mark
"Joerg Jooss" wrote:
Hello Mark,
I wrote that function but if I can, I would rather do it within the
framework .

"ISO Latin 1" isn't an option in system.text.enc oding.

Is there some other encoding method in the framework?


ISO Latin 1 is an alias for ISO-8859-1. You can create an instance either
by name

Encoding latin1 = Encoding.GetEnc oding("ISO-8859-1");

or by its Windows code page number

Encoding latin1 = Encoding.GetEnc oding(28591);

Cheers,
--
Joerg Jooss
ne********@joer gjooss.de

Feb 1 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
5450
by: Dave Smithz | last post by:
Hi There, I have a PHP script that sends an email with attachment and works great when provided the path to the file to send. However this file needs to be on the same server as the script. I want to develop a webpage where people can send attachments that are stored on their local PC.
0
1629
by: someone | last post by:
I am in a situation where I need to package some information from Page1, submit it via POST to another server which will process the information and then send the user to another page on my server (Page2). I have looked at HttpWebRequest (see code below) on numerous coding websites but have not found a method that works. Does anyone have a solution for this or has seen an example that works for this situation?
3
5148
by: George Hester | last post by:
http://support.microsoft.com/default.aspx?scid=kb;en-us;301464 Look down at the MyPage.asp example. You will see that Microsoft does this: 'Costruct the URL for the current page s = "http://" s = s & Request.ServerVariables("HTTP_HOST") s = s & Request.ServerVariables("URL") If Request.QueryString.Count > 0 Then s = s & "?" & Request.QueryString
3
7638
by: JP SIngh | last post by:
Hi All I have users who upload files using my application using ASPUPLOAD component. My code uploads the file to a network location and once the upload is finish I display the hyperlink using the following code <a href=\myserver\attachments\<%=server.urlencode(rs("FileName"))%> target="_blank" ><%=rs("Filename")%>
4
6732
by: Andreas Klemt | last post by:
Hello, is there a difference between System.Web.HttpUtility.UrlEncode and Server.UrlEncode ?
6
2068
by: someone | last post by:
I am in a situation where I need to package some information from Page1, submit it via POST to another server which will process the information and then send the user to another page on my server (Page2). I have looked at HttpWebRequest on numerous coding websites but have not found a method that works. Does anyone have a solution for this or has seen an example that works for this situation? This is one very frustrating issue that I...
1
5363
by: Dario Sala | last post by:
Hi, what's the difference about Asp Server.UrlEncode and the Asp.Net Server.UrlEncode ? In asp: Server.UrlEncode("*") = %2A In Asp.Net: Server.UrlEncode("*") = *
0
1207
by: Nathan Sokalski | last post by:
I am using Server.UrlEncode to make a piece of data safe to use as a QueryString. The data I am using is as follows: ratedpoem("title") Which returns the following String: "An Expression I Can't Show"
19
1882
by: Extremist | last post by:
Hi there, I have an application written in Python 2.3, wxPython 2.4 , C++, OpenGL OS: Fedora Core 3 Now I need to upgrade it using Python 2.4 and wxPython 2.6 OS: Fedora Core 6 There was a few minor faults and it was easy to fix But now I get this Segmentation fault error message What is the diffrences between Python 2.3 and Python 2.4?
0
8266
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
8638
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8365
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8505
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6125
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5574
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4092
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2626
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1811
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.