473,322 Members | 1,540 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Response.Redirect: Need ISO-8859-1 instead of utf-8

I need to redirect the user to an external page and include some information
in the querystring (is this possible to do as a post instead of get?) I'm
using Response.Redirect. The problem occurs if the information contains
local characters (like åäö.) The external page can only handle ISO-8859. If
I check the browser's address bar, local characters are in 'plain' text. I
tried using Server.Encode, but then I got them in utf-8. Is it possible to
get ISO-8859-1?

Peter
Nov 19 '05 #1
6 6750
Add a <meta> tag.

<meta http-equiv="content-type" content="text/html;
charset=ISO-8859-1">

in <head> section
-- OR --
Add

<%@ Page ContentType="text/html; charset=...." %>

--
Cheers,
Gaurav Vaish
http://mastergaurav.org
http://mastergaurav.blogspot.com
------------------------------------

Nov 19 '05 #2
Oops!
ERRATA:

In ASP and ASP.Net, content type and charset are set independently, and
are methods on the response object. To set the charset, use e.g.:

<% Response.Charset="utf-8"%>

In ASP.Net, setting Response.ContentEncoding will take care both of the
charset parameter in the HTTP Content-Type as well as of the actual
encoding of the document sent out (which of course have to be the
same). The default can be set in the globalization element in
Web.config (or Machine.config, which is originally set to UTF-8).

For web.config / machine.config file - check the globalization element.

I would suggest -- prefer using meta tag.
--
Cheers,
Gaurav Vaish
http://mastergaurav.org
http://mastergaurav.blogspot.com
------------------------------------

Nov 19 '05 #3
"MasterGaurav" <ga**********@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Oops!
ERRATA:

In ASP and ASP.Net, content type and charset are set independently, and
are methods on the response object. To set the charset, use e.g.:

<% Response.Charset="utf-8"%>

In ASP.Net, setting Response.ContentEncoding will take care both of the
charset parameter in the HTTP Content-Type as well as of the actual
encoding of the document sent out (which of course have to be the
same). The default can be set in the globalization element in
Web.config (or Machine.config, which is originally set to UTF-8).

For web.config / machine.config file - check the globalization element.

I would suggest -- prefer using meta tag.


Setting Response.Charset didn't work. I tried the following:

Response.Charset = "ISO-8859-1";
Response.Redirect(url);

If I enter 'pÅÄÖp' as the name, I get the following in the querystring:

name=p%c3%85%c3%84%c3%96p

The external page shows other weird characters.
Peter
Nov 19 '05 #4
Found a solution (perhaps not the easiest one, but it seems to work):

// string str will be converted to string ret.
System.Text.Encoding enc = System.Text.Encoding.GetEncoding(28591);

byte[] byteArray = new byte[str.Length];

int count = enc.GetBytes(str, 0, str.Length, byteArray, 0);

string[] cs = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b",
"c", "d", "e", "f"};

for (int i = 0; i < count; i++) {

int lb = 0;

int hb = System.Math.DivRem((int) byteArray[i], 16, out lb);

ret += "%" + cs[hb] + cs[lb];

}

Peter


Nov 19 '05 #5
Peter Laan wrote:
I need to redirect the user to an external page and include some
information in the querystring (is this possible to do as a post
instead of get?) I'm using Response.Redirect. The problem occurs if
the information contains local characters (like åäö.) The external
page can only handle ISO-8859. If I check the browser's address bar,
local characters are in 'plain' text. I tried using Server.Encode,
but then I got them in utf-8. Is it possible to get ISO-8859-1?


See System.Web.HttpUtility. Unlike System.Web.HttpServerUtility, it
allows you to specify a character encoding directly.

Cheers.
--
http://www.joergjooss.de
mailto:ne********@joergjooss.de
Nov 19 '05 #6
"Joerg Jooss" <ne********@joergjooss.de> wrote in message
See System.Web.HttpUtility. Unlike System.Web.HttpServerUtility, it
allows you to specify a character encoding directly.


Thanks! That's exactly what I was looking for.

Peter
Nov 19 '05 #7

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

Similar topics

3
by: Paul | last post by:
I'm not getting the results I want when I use Response.Redirct in a ASP page. I enter this line of code in a asp page from domain1.com. Response.Redirect...
8
by: Daniel | last post by:
Hello, I have an old asp page that was used to redirect users called redirect.asp: <code1> <% Option Explicit If Request.QueryString("url") <> "" Then Response.Redirect ...
4
by: TomT | last post by:
Hi.. I'm redirecting users to another page using: response.redirect("newpage.asp") this works... But I need to add a variable to the page specified.. IE: newpage.asp?id=JobID
2
by: Brian | last post by:
I'm trying to response.redirect to another page on a button click event and I get an error message stating that the thread was being aborted (if I trap for the error that is...) I've researched...
6
by: Keith Patrick | last post by:
I have to do some programmatic redirects (in several pages) based on URLs I am given from an external source. The URLs have querystrings at the end, but one in particular is about 240 chars long,...
4
by: Dot net work | last post by:
I have noticed that this: Response.Redirect("/MyLocalDirectory/MyPage.aspx") seems to be a lot quicker than this: Response.Redirect(sDirectoryString & "MyPage.aspx") In local...
10
by: Niggy | last post by:
I get an error - any help appreciated. System.Threading.ThreadAbortException: Thread was being aborted. at System.Threading.Thread.AbortInternal() at System.Threading.Thread.Abort(Object...
4
by: mike.biang | last post by:
I have an ASP page that is using an XMLHTTP object to request various pages from my server. I keep a single session throughout the XMLHTTP requests by bassing the ASPSESSIONID cookie through the...
1
by: nettleby | last post by:
The Microsoft site has confused me on this issue: http://www.microsoft.com/technet/prodtechnol/windows2000serv/reskit/iisbook/c06_redirection.mspx?mfr=true Says that: "ASP automatically discards...
11
by: Paul Furman | last post by:
I'm setting up credit card payment through authorize.net and they have the option to send a POST string back to my site once complete. I'm not sure how to proceed. They don't have much to read...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

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.