473,395 Members | 2,006 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,395 software developers and data experts.

French characters in query string

Hello,

How can I convert an url encoded string containing some french
characters back to the original string?

I have the following html form:
<form>
name = <input type="text" name="name" value="Noël Pirès"/>
<input type="submit" value="OK"/>
</form>

When I submit this form the following data is sent at protocol level
using HTTP GET: name=No%EBl+Pir%E8s

I tried converting it with the HttpUtility.UrlDecode method in order
to obtain the original string but with no success. This method
returned
"name=Nol Pirs" and the special french characters are omitted. What
function should I use in order to decode such a string.

In fact I would like to implement the following: I have a text file
containing the urlencoded string and in a console application I want
to make the conversion, something like:

------------------------
FileStream fin = new FileStream(@"c:\test.txt", FileMode.Open,
FileAccess.read);
byte[] buf = new byte[fin.Length];
fin.Read(buf, 0, (int)buf.Length);
string s = Encoding.Default.GetString(buf);

s = HttpUtility.UrlDecode(s);
System.Console.Write(s);
------------------------

and the test.txt file:
------------------------
name=No%EBl+Pir%E8s
------------------------
Any suggestions?
Jul 21 '05 #1
5 2819
darin dimitrov <da************@hotmail.com> wrote:
How can I convert an url encoded string containing some french
characters back to the original string?


As far as I know, there's not much in the way of standardisation for
what URL encodings mean above the top of ASCII. The most robust way of
proceeding, IMO, is to use post data instead.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #2
Jon Skeet [C# MVP] <sk***@pobox.com> wrote in message news:<MP************************@msnews.microsoft. com>...
darin dimitrov <da************@hotmail.com> wrote:
How can I convert an url encoded string containing some french
characters back to the original string?


As far as I know, there's not much in the way of standardisation for
what URL encodings mean above the top of ASCII. The most robust way of
proceeding, IMO, is to use post data instead.

I will post the solution I found myself in case that someone else
might be interested:

The problem was that when I use the HttpUtility.UrlDecode methode
there is no way to specify the encoding, so instead I used the
HttpUtility.UrlDecodeToBytes method like:

<code>
string s = "name=No%EBl+Pir%E8s";
byte[] binaryData = HttpUtility.UrlDecodeToBytes(s,
Encoding.Default);
s = Encoding.Default.GetString(binaryData);
</code>

Now s = "name=Noël Pirès"
Jul 21 '05 #3
darin dimitrov <da************@hotmail.com> wrote:
As far as I know, there's not much in the way of standardisation for
what URL encodings mean above the top of ASCII. The most robust way of
proceeding, IMO, is to use post data instead.


I will post the solution I found myself in case that someone else
might be interested:

The problem was that when I use the HttpUtility.UrlDecode methode
there is no way to specify the encoding, so instead I used the
HttpUtility.UrlDecodeToBytes method like:

<code>
string s = "name=No%EBl+Pir%E8s";
byte[] binaryData = HttpUtility.UrlDecodeToBytes(s,
Encoding.Default);
s = Encoding.Default.GetString(binaryData);
</code>

Now s = "name=Noël Pirès"


That's fine so long as you know that the client was using the same
encoding - but do you?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #4
Jon Skeet [C# MVP] <sk***@pobox.com> wrote in message news:<MP************************@msnews.microsoft. com>...
darin dimitrov <darin di******@hotmail.com> wrote:
As far as I know, there's not much in the way of standardisation for
what URL encodings mean above the top of ASCII. The most robust way of proceeding, IMO, is to use post data instead.


I will post the solution I found myself in case that someone else
might be interested:

The problem was that when I use the HttpUtility.UrlDecode methode
there is no way to specify the encoding, so instead I used the
HttpUtility.UrlDecodeToBytes method like:

<code>
string s = "name=No%EBl+Pir%E8s";
byte[] binaryData = HttpUtility.UrlDecodeToBytes(s,
Encoding.Default);
s = Encoding.Default.GetString(binaryData);
</code>

Now s = "name=No l Pir s"


That's fine so long as you know that the client was using the same
encoding - but do you?

In my particular case I know the encoding that my clients are using,
but I agree that this is not a general solution. I would appreciate
any better suggestions.
Jul 21 '05 #5
darin dimitrov <da************@hotmail.com> wrote:
That's fine so long as you know that the client was using the same
encoding - but do you?


In my particular case I know the encoding that my clients are using,
but I agree that this is not a general solution. I would appreciate
any better suggestions.


As I said before, a much better way of passing data is in the body of
the request, as that has an encoding associated with it.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #6

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

Similar topics

3
by: Salgoud Dell | last post by:
I have a VB6 application running on a French computer using Windows ME. The app doesn't work the same way as it does when running on an English Windows OS. The main issue I have, that I can't...
0
by: Mirza Khodabaccus | last post by:
Hi, Thanks for the reply that Mr John Robert sent me, but i have already tried the urlencode and urldecode but it did not work. my question is that, I am having a big problem reading french...
8
by: Ess355 | last post by:
Hi, In the debugger at run time, characters like é are not recognised by their normal ASCII number, but something like -8615722... . I've seen this number before, it means "rubbish" right? So...
4
by: Lu | last post by:
Hi, i am currently working on ASP.Net v1.0 and is encountering the following problem. In javascript, I'm passing in: "somepage.aspx?QSParameter=<RowID>Chèques</RowID>" as part of the query...
5
by: darin dimitrov | last post by:
Hello, How can I convert an url encoded string containing some french characters back to the original string? I have the following html form: <form> name = <input type="text" name="name"...
9
by: kaustubh.deo | last post by:
I am facing issues printing french chars like using printf function. I have reproduced this issue with simple C program as follows. #include <stdio.h> #include <locale.h> int main(int...
1
by: prasadoo | last post by:
Hi everyone, I am trying to populate DropDownList with French characters but for some characters like é,d' etc.it is not showing the exacts French characters. Can anybody help me how to populate...
4
by: Rob | last post by:
Hi, I have a small VB.Net program that reads in an HTML file using a FileStream (this file was created by MS Word "Save as HTML" feature), uses regular expressions to remove all unwanted code...
0
by: shintu | last post by:
Hallo, I am trying to write french accented characters é è ê in Excel worksheet using my perl script , But I am stuck here as I couldnt find a way of writing it !: My code: use strict;...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...
0
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.