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.Url Decode 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.Defaul t.GetString(buf );
s = HttpUtility.Url Decode(s);
System.Console. Write(s);
------------------------
and the test.txt file:
------------------------
name=No%EBl+Pir %E8s
------------------------
Any suggestions? 5 2842
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.co m> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jon Skeet [C# MVP] <sk***@pobox.co m> wrote in message news:<MP******* *************** **@msnews.micro soft.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.Url Decode methode
there is no way to specify the encoding, so instead I used the
HttpUtility.Url DecodeToBytes method like:
<code>
string s = "name=No%EBl+Pi r%E8s";
byte[] binaryData = HttpUtility.Url DecodeToBytes(s ,
Encoding.Defaul t);
s = Encoding.Defaul t.GetString(bin aryData);
</code>
Now s = "name=Noël Pirès"
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.Url Decode methode there is no way to specify the encoding, so instead I used the HttpUtility.Url DecodeToBytes method like: <code> string s = "name=No%EBl+Pi r%E8s"; byte[] binaryData = HttpUtility.Url DecodeToBytes(s , Encoding.Defaul t); s = Encoding.Defaul t.GetString(bin aryData); </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.co m> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jon Skeet [C# MVP] <sk***@pobox.co m> wrote in message news:<MP******* *************** **@msnews.micro soft.com>... darin dimitrov <darin di******@hotmai l.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.Url Decode methode there is no way to specify the encoding, so instead I used the HttpUtility.Url DecodeToBytes method like:
<code> string s = "name=No%EBl+Pi r%E8s"; byte[] binaryData = HttpUtility.Url DecodeToBytes(s , Encoding.Defaul t); s = Encoding.Defaul t.GetString(bin aryData); </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.
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.co m> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 seem to overcome, is that the english
text font size my program thinks is available doesn't seem to be there.
Although a line of text printed on a US Windows machine looks fine, when it
is printed from this French computer the tabs are over written...
|
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 characters from
the query string, that is from the url.
|
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 how can I possible modify my program so that french characters get
recognised?
Thanks in advance,
|
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
string. However, in the code behind when I tried to get the query string
value by calling Request.QueryString("QSParameter"), the value I got is:
"<RowID>Chques</RowID>". The special character "è" has been stripped out.
The web.config file is...
|
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" value="Noël Pirès"/>
<input type="submit" value="OK"/>
</form>
| |
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 argc, char **argv)
{
|
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 DropDownList with French characters.
|
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 and then re-writes
the file.
It works fine but when I execute this on a french web page...the
StreamWriter removes all of the french characters. Here's a piece of the
code:
|
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;
use warnings;
|
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, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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,...
| |
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |