473,657 Members | 2,266 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

German "Umlaute" in QueryString

Hello,

working on a asp.net Website brought me to a strange problem.

I want to enable my users to pass a search string via the query string
of an url.

It works if the user calls the URL like "default.aspx?s earch=mystring"
But as soon as a German umlaut is in the query string it does not
handle the char correctly (like "default.aspx?s earch=müstring " will be
displayed as "m?string" on the page).

I notice that firefox converts the URL automatically to:
?search=m%FCstr ing
using the debugger results in:
Request.QuerySt ring = {search=m%ufffd string}
the display as label is:
m�string

If I call the page from another asp.net page using
Response.Redire ct("Default.asp x?search=" +
Server.UrlEncod e("müstring")) ;
the result is corretly, but the URL is changed to:
?search=m%c3%bc string
debugging results in
Request.QuerySt ring = {search=m%u00fc string}

The problem is, that the users will call the URL from different
applications (not necessarily .NET) so Server.URLEncod e will never be
called so the first case will occur.

How can I solve this?

Thank you!
Regards,
Uwe
Aug 11 '08 #1
12 8035
Needs to be treated as unicode. Look at requestEncoding , responseEncodin g
and the related configuration entries in MSDN under globalization node in
the web.config file. May throw some light.
"Uwe Braunholz" <uw***********@ hotmail.dewrote in message
news:d9******** *************** ***********@79g 2000hsk.googleg roups.com...
Hello,

working on a asp.net Website brought me to a strange problem.

I want to enable my users to pass a search string via the query string
of an url.

It works if the user calls the URL like "default.aspx?s earch=mystring"
But as soon as a German umlaut is in the query string it does not
handle the char correctly (like "default.aspx?s earch=müstring" will be
displayed as "m?string" on the page).

I notice that firefox converts the URL automatically to:
?search=m%FCstr ing
using the debugger results in:
Request.QuerySt ring = {search=m%ufffd string}
the display as label is:
m?string

If I call the page from another asp.net page using
Response.Redire ct("Default.asp x?search=" +
Server.UrlEncod e("müstring") );
the result is corretly, but the URL is changed to:
?search=m%c3%bc string
debugging results in
Request.QuerySt ring = {search=m%u00fc string}

The problem is, that the users will call the URL from different
applications (not necessarily .NET) so Server.URLEncod e will never be
called so the first case will occur.

How can I solve this?

Thank you!
Regards,
Uwe
Aug 11 '08 #2
Hello Sriram,
thank you for your answer. I thougth so too, but the default seems to
be utf-8. If I set
<globalizatio n requestEncoding ="UTF-8" responseEncodin g="UTF-8" />
in web.config, nothing changes. Only if I set a different encoding
like "ISO-8859-1". But what if another user enters some greek, russian
or chinese characters?

I think fixing my application to a specific encoding is not a good
idea. I thought utf8 would be the choice for that?

Regards,
Uwe

On 11 Aug., 12:00, "Sriram Srivatsan" <sriramsrivat.. .@srasys.co.in>
wrote:
Needs to be treated as unicode. *Look at requestEncoding , responseEncodin g
and the related configuration entries in MSDN under globalization node in
the web.config file. May throw some light.

"Uwe Braunholz" <uwe.braunh...@ hotmail.dewrote in message

news:d9******** *************** ***********@79g 2000hsk.googleg roups.com...
Hello,

working on a asp.net Website brought me to a strange problem.

I want to enable my users to pass a search string via the query string
of an url.

It works if the user calls the URL like "default.aspx?s earch=mystring"
But as soon as a German umlaut is in the query string it does not
handle the char correctly (like "default.aspx?s earch=müstring" will be
displayed as "m?string" on the page).

I notice that firefox converts the URL automatically to:
?search=m%FCstr ing
using the debugger results in:
Request.QuerySt ring = {search=m%ufffd string}
the display as label is:
m?string

If I call the page from another asp.net page using
Response.Redire ct("Default.asp x?search=" +
Server.UrlEncod e("müstring") );
the result is corretly, but the URL is changed to:
?search=m%c3%bc string
debugging results in
Request.QuerySt ring = {search=m%u00fc string}

The problem is, that the users will call the URL from different
applications (not necessarily .NET) so Server.URLEncod e will never be
called so the first case will occur.

How can I solve this?

Thank you!
Regards,
Uwe
Aug 11 '08 #3
On Aug 11, 11:44*am, Uwe Braunholz <uwe.braunh...@ hotmail.dewrote :
Hello,

working on a asp.net Website brought me to a strange problem.

I want to enable my users to pass a search string via the query string
of an url.

It works if the user calls the URL like "default.aspx?s earch=mystring"
But as soon as a German umlaut is in the query string it does not
handle the char correctly (like "default.aspx?s earch=müstring" will be
displayed as "m?string" on the page).

I notice that firefox converts the URL automatically to:
?search=m%FCstr ing
using the debugger results in:
Request.QuerySt ring = {search=m%ufffd string}
the display as label is:
m string

If I call the page from another asp.net page using
Response.Redire ct("Default.asp x?search=" +
Server.UrlEncod e("müstring") );
the result is corretly, but the URL is changed to:
?search=m%c3%bc string
debugging results in
Request.QuerySt ring = {search=m%u00fc string}

The problem is, that the users will call the URL from different
applications (not necessarily .NET) so Server.URLEncod e will never be
called so the first case will occur.

How can I solve this?

Thank you!
Regards,
Uwe
Hallo Uwe,

generally all umlauts must be encoded (as UTF-8 in your case).

So, if your search string value is from the Search textbox, you have
to encode it as

string search = HttpUtility.Url Encode(SearchTe xtBox.Text,
Encoding.UTF8)) ;
Response.Redire ct("default.asp x?search=" + search);

this would redirect you to default.aspx?se arch=m%c3%bcstr ing

In this case you would not have any problem to get the value using
HttpUtility.Url Decode() function...

If you want to get umlauts out of the "default.aspx?s earch=müstring"
use RawUrl:

string search = Request.RawUrl. Split('=')[1];

and then search would return you "müstring". ..

To handle both requests

default.aspx?se arch=m%c3%bcstr ing
default.aspx?se arch=müstring

use

string search = Request.RawUrl. Split('=')[1];
string newsearch = HttpUtility.Url Decode(search);
Aug 11 '08 #4
Hello Alexey,

thank you for your reply. Unfortunately even the RawUrl does not give
me the real (intended) URL-string. There still is a ? instead of the
"ü".
Debugging says
Request.QuerySt ring = {search=m%ufffd string}
Request.RawUrl = "/WebSite2/Default.aspx?se arch=m�string "

The problem is that I do not have any control over the search-source.
This could be any application where the url is put together
automatically.

Regards,
Uwe

On 11 Aug., 13:37, Alexey Smirnov <alexey.smir... @gmail.comwrote :
On Aug 11, 11:44Â*am, Uwe Braunholz <uwe.braunh...@ hotmail.dewrote :
Hello,
working on a asp.net Website brought me to a strange problem.
I want to enable my users to pass a search string via the query string
of an url.
It works if the user calls the URL like "default.aspx?s earch=mystring"
But as soon as a German umlaut is in the query string it does not
handle the char correctly (like "default.aspx?s earch=müstring " will be
displayed as "m?string" on the page).
I notice that firefox converts the URL automatically to:
?search=m%FCstr ing
using the debugger results in:
Request.QuerySt ring = {search=m%ufffd string}
the display as label is:
m string
If I call the page from another asp.net page using
Response.Redire ct("Default.asp x?search=" +
Server.UrlEncod e("müstring")) ;
the result is corretly, but the URL is changed to:
?search=m%c3%bc string
debugging results in
Request.QuerySt ring = {search=m%u00fc string}
The problem is, that the users will call the URL from different
applications (not necessarily .NET) so Server.URLEncod e will never be
called so the first case will occur.
How can I solve this?
Thank you!
Regards,
Uwe

Hallo Uwe,

generally all umlauts must be encoded (as UTF-8 in your case).

So, if your search string value is from the Search textbox, you have
to encode it as

string search = HttpUtility.Url Encode(SearchTe xtBox.Text,
Encoding.UTF8)) ;
Response.Redire ct("default.asp x?search=" + search);

this would redirect you to default.aspx?se arch=m%c3%bcstr ing

In this case you would not have any problem to get the value using
HttpUtility.Url Decode() function...

If you want to get umlauts out of the "default.aspx?s earch=müstring "
use RawUrl:

string search = Request.RawUrl. Split('=')[1];

and then search would return you "müstring" ...

To handle both requests

default.aspx?se arch=m%c3%bcstr ing
default.aspx?se arch=müstring

use

string search = Request.RawUrl. Split('=')[1];
string newsearch = HttpUtility.Url Decode(search);
Aug 11 '08 #5
On Aug 11, 3:10*pm, Uwe Braunholz <uwe.braunh...@ hotmail.dewrote :
Hello Alexey,

thank you for your reply. Unfortunately even the RawUrl does not give
me the real (intended) URL-string. There still is a ? instead of the
"ü".
Debugging says
Request.QuerySt ring = {search=m%ufffd string}
Request.RawUrl = "/WebSite2/Default.aspx?se arch=m string"
Well, but where did you get the "m%ufffdstring" ?

%ufff is wrong there... you can simply check it by typing "müstring"
in google. When UTF8 is used you will see that url is encoded as "m
%C3%BCstring"

http://www.google.com/search?hl=en&q=m%C3%BCstring

and not

http://www.google.com/search?hl=en&q=m%25ufffdstring
Aug 11 '08 #6
Hello Alexey,

the "m%ufffdstr ing" appears, if I hover the variable in my Visual
Studio 2005 with my mouse.

Regards,
Uwe

On 11 Aug., 17:05, Alexey Smirnov <alexey.smir... @gmail.comwrote :
On Aug 11, 3:10*pm, Uwe Braunholz <uwe.braunh...@ hotmail.dewrote :
Hello Alexey,
thank you for your reply. Unfortunately even the RawUrl does not give
me the real (intended) URL-string. There still is a ? instead of the
"ü".
Debugging says
Request.QuerySt ring = {search=m%ufffd string}
Request.RawUrl = "/WebSite2/Default.aspx?se arch=m string"

Well, but where did you get the "m%ufffdstring" ?

%ufff is wrong there... you can simply check it by typing "müstring"
in google. When UTF8 is used you will see that url is encoded as "m
%C3%BCstring"

http://www.google.com/search?hl=en&q=m%C3%BCstring

and not

http://www.google.com/search?hl=en&q=m%25ufffdstring
Aug 12 '08 #7
Ok, I think the problem is about that:
http://www.captain.at/howto-php-urle...IComponent.php

Assuming, I will never be able to pass a regular ü to the server by
simply put it into the url:
The Server.UrlEncod e converts ü to %C3%BC
But my browsers convert ü to %FC
Why is this? How do I know what I will get on the serverside?

Regards,
Uwe

On 11 Aug., 17:05, Alexey Smirnov <alexey.smir... @gmail.comwrote :
On Aug 11, 3:10*pm, Uwe Braunholz <uwe.braunh...@ hotmail.dewrote :
Hello Alexey,
thank you for your reply. Unfortunately even the RawUrl does not give
me the real (intended) URL-string. There still is a ? instead of the
"ü".
Debugging says
Request.QuerySt ring = {search=m%ufffd string}
Request.RawUrl = "/WebSite2/Default.aspx?se arch=m string"

Well, but where did you get the "m%ufffdstring" ?

%ufff is wrong there... you can simply check it by typing "müstring"
in google. When UTF8 is used you will see that url is encoded as "m
%C3%BCstring"

http://www.google.com/search?hl=en&q=m%C3%BCstring

and not

http://www.google.com/search?hl=en&q=m%25ufffdstring
Aug 12 '08 #8
On Aug 12, 8:03*am, Uwe Braunholz <uwe.braunh...@ hotmail.dewrote :
Ok, I think the problem is about that:http://www.captain.at/howto-php-urle...codeURICompone...

Assuming, I will never be able to pass a regular ü to the server by
simply put it into the url:
The Server.UrlEncod e converts ü to %C3%BC
But my browsers convert ü to %FC
Why is this? How do I know what I will get on the serverside?

Regards,
Uwe

On 11 Aug., 17:05, Alexey Smirnov <alexey.smir... @gmail.comwrote :
On Aug 11, 3:10*pm, Uwe Braunholz <uwe.braunh...@ hotmail.dewrote :
Hello Alexey,
thank you for your reply. Unfortunately even the RawUrl does not give
me the real (intended) URL-string. There still is a ? instead of the
"ü".
Debugging says
Request.QuerySt ring = {search=m%ufffd string}
Request.RawUrl = "/WebSite2/Default.aspx?se arch=m string"
Well, but where did you get the "m%ufffdstring" ?
%ufff is wrong there... you can simply check it by typing "müstring"
in google. When UTF8 is used you will see that url is encoded as "m
%C3%BCstring"
http://www.google.com/search?hl=en&q=m%C3%BCstring
and not
http://www.google.com/search?hl=en&q=m%25ufffdstring- Hide quoted text -

- Show quoted text -
Uwe,

you used Firefox 2 to get the "ü" converted into "%FC", right? While
FF2 sends it by default in ISO-8859-1, FF3 and IE send it in UTF-8 and
that means that you cannot get "ü" working in FF2 only. But in FF2 you
can change this behavior too. Go to about:config, and set
"network.standa rd-url.encode-utf8" parameter to true.

If you want to make umlauts working in all browsers I guess you would
need to check if letter has 1 or 2 bytes encoded. But the easiest way
is probably to use a function as the one below:

string convertLetters( string s)
{
string[] oldchars = new string[] {"%FC","%C3%BC" , ...};
string[] newchars = new string[] {"ü","ü", "ä", "ö"...};

for (i==0;i<oldchar s.length();i++)
{
if (s.indexOf(oldc hars[i])>-1)
{
s = s.replace(oldch ars[i],newchars[i]);
}
}

return s;
}
Aug 12 '08 #9
Hello Alexey,

thanks for keeping up on this!
I am using FF3, but the settings was false, so I assume the behavior
did not change. As I switched to true, it worked.
On my testmachine I use IE6 as well, and this one does not seem to use
UTF8 also, because the result is the same.

How could I check if the string is encoded with one or two bytes?

Regards,
uwe

On 12 Aug., 09:34, Alexey Smirnov <alexey.smir... @gmail.comwrote :
On Aug 12, 8:03*am, Uwe Braunholz <uwe.braunh...@ hotmail.dewrote :
Ok, I think the problem is about that:http://www.captain.at/howto-php-urle...codeURICompone...
Assuming, I will never be able to pass a regular ü to the server by
simply put it into the url:
The Server.UrlEncod e converts ü to %C3%BC
But my browsers convert ü to %FC
Why is this? How do I know what I will get on the serverside?
Regards,
Uwe
On 11 Aug., 17:05, Alexey Smirnov <alexey.smir... @gmail.comwrote :
On Aug 11, 3:10*pm, Uwe Braunholz <uwe.braunh...@ hotmail.dewrote :
Hello Alexey,
thank you for your reply. Unfortunately even the RawUrl does not give
me the real (intended) URL-string. There still is a ? instead of the
"ü".
Debugging says
Request.QuerySt ring = {search=m%ufffd string}
Request.RawUrl = "/WebSite2/Default.aspx?se arch=m string"
Well, but where did you get the "m%ufffdstring" ?
%ufff is wrong there... you can simply check it by typing "müstring"
in google. When UTF8 is used you will see that url is encoded as "m
%C3%BCstring"
>http://www.google.com/search?hl=en&q=m%C3%BCstring
and not
>http://www.google.com/search?hl=en&q...ffdstring-Hide quoted text -
- Show quoted text -

Uwe,

you used Firefox 2 to get the "ü" converted into "%FC", right? While
FF2 sends it by default in ISO-8859-1, FF3 and IE send it in UTF-8 and
that means that you cannot get "ü" working in FF2 only. But in FF2 you
can change this behavior too. Go to about:config, and set
"network.standa rd-url.encode-utf8" parameter to true.

If you want to make umlauts working in all browsers I guess you would
need to check if letter has 1 or 2 bytes encoded. But the easiest way
is probably to use a function as the one below:

string convertLetters( string s)
{
string[] oldchars = new string[] {"%FC","%C3%BC" , ...};
string[] newchars = new string[] {"ü","ü", "ä", "ö"...};

for (i==0;i<oldchar s.length();i++)
{
if (s.indexOf(oldc hars[i])>-1)
{
s = s.replace(oldch ars[i],newchars[i]);

}
}

return s;

}

Aug 12 '08 #10

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

Similar topics

13
8520
by: Robert Zierhofer | last post by:
Hi all, I currently face a problem with htmlentities and german "umlaute". After moving my scripts to a new box (from Linux to FreeBSD) I had to see that htmlentities is not working anymore. The BSD Server (FreeBSD 5.1.2) runs PHP 4.3.9 and Apache 2 as well as the Linux Server does/did too. I also tried defining the charset with ISO 8859-1 as 3rd parameter in htmlentities but without a result.
16
4902
by: Dany | last post by:
Our web service was working fine until we installed .net Framework 1.1 service pack 1. Uninstalling SP1 is not an option because our largest customer says service packs marked as "critical" by Microsoft must be installed on their servers. Now german Umlaute (ä, ü, ö) and quotes are returned incorrectly in SOAP fault responses. This can be easily verified: Implement the following in a web service method (just raises a SOAPException with a...
0
8319
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8837
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8512
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
8612
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
6175
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
5638
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
4171
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...
0
4329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1969
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.