Re: Error decoding ISO character 147 by peterstroeiman
peterstroeiman
Mon Sep 25 03:33:40 CDT 2006
I think I figured out that the root of my problem is that that
particular character does not exist at all in iso-8859-1. Therefore
ideologically the browser should not allow that character to be entered
- but it does.
I guess this is kinda like if someone entered Chinese characters into a
textbox. Those would be impossible to submit as well using ISO encoding.
But unfortunately the browser does not care that that particular
character is impossible to transmit using the specific encoding, and
transmits it anyway.
/Pete
Morten Wennevik wrote:
> Well, you can test for Request.Encoding, or just swap your encoding with
> Windows-1252
>
>
> On Fri, 22 Sep 2006 14:00:03 +0200, Peter Strøiman
> <peterstroeiman@nospam.nospam> wrote:
>
>> Peter Strøiman wrote:
>>> Hi
>>> I have a byte-array, in which one of the bytes has the value 149
>>> (hex95) which represents a dot ( â?¢ ). The same character has the
>>> unicode value of 8226 (hex 2022)
>>> But when I try to decode the byte-array into a string, that
>>> character is not converted into the correct value.
>>> If I use the following code:
>>> byte[] b = new byte[] { 147 };
>>> char[] c = System.Text.Encoding.GetEncoding("ISO-8859-1").GetChars(b);
>>> c now contains the character value 147 - which is an illegal unicode
>>> value.
>>> What am I doing wrong (actually asp.net is doing it wrong as well,
>>> because if I enter that character in a text-field, then the wrong
>>> value is stored in the database. So the character is not properly
>>> decoded when the form is posted to the server)
>>> Regards,
>>> Pete
>>
>> Ahh - I was mistaken - 147 is not the ISO code for that character, it
>> is the windows-code for that particular character. So I guess my
>> problem now is, that my browser is using Windows-encoding instead of
>> ISO when posting the request.
>
>
>
> --Happy Coding!
> Morten Wennevik [C# MVP]