Thursday, March 22, 2012
Server.HTMLDecode doesn't decode char 345
I have a problem decoding the czech character:
r
The HTML code for this character is ř but when running
Server.HTMLdecode on that string it just returns ř instead of the real
char. (It works on a lot of other characters)
I need to decode this string in order to render an image with this character
as a part of a headline.
Can anyone help me with this issue, or is it maybe a bug?
/kindest regards, JonasThis works fine for me:
Response.Write(Server.HtmlDecode("ř"));
My web.config specifies:
<globalization requestEncoding="utf-8" responseEncoding="utf-8" />
maybe yours is using something else?
Karl
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Jonas kermark" <jonas@.wipcore.se> wrote in message
news:uY3DJazlFHA.2080@.TK2MSFTNGP14.phx.gbl...
> Hello!
> I have a problem decoding the czech character:
> r
> The HTML code for this character is ř but when running
> Server.HTMLdecode on that string it just returns ř instead of the
> real char. (It works on a lot of other characters)
> I need to decode this string in order to render an image with this
> character as a part of a headline.
> Can anyone help me with this issue, or is it maybe a bug?
> /kindest regards, Jonas
>
Maybe it is because I'm usning the Server object in a function in a non web
environment - a regular class:
string decodedText = System.Web.HttpContext.Current.Server.HtmlDecode(
text );
where the text property sometimes contains the char ř
Is there some way that I can tell the HtmlDecode which encoding to use?
/Jonas
"Karl Seguin" <karl REMOVE @. REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:%23o0ElR1lFHA.3552@.TK2MSFTNGP10.phx.gbl...
> This works fine for me:
> Response.Write(Server.HtmlDecode("ř"));
> My web.config specifies:
> <globalization requestEncoding="utf-8" responseEncoding="utf-8" />
> maybe yours is using something else?
> Karl
> --
> MY ASP.Net tutorials
> http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
> http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
> come!)
>
> "Jonas kermark" <jonas@.wipcore.se> wrote in message
> news:uY3DJazlFHA.2080@.TK2MSFTNGP14.phx.gbl...
>
i don't think that's your problem (although within a class, there's no
reason not to use System.Web.HttpUtility.HtmlDecode which decouples your
class from the context (ie, it can be reused outside of the web)).
All HtmlDecode does in the case of a numeric value (such as 345), is:
char c1 = (char) ((ushort) int.Parse("345"));
Response.Write(c1);
Is your page encoding set to utf-8? (if you put tracing on, at the top of
the trace information it says the encoding).l
Karl
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Jonas kermark" <jonas@.wipcore.se> wrote in message
news:OELxjb1lFHA.2904@.TK2MSFTNGP14.phx.gbl...
> Maybe it is because I'm usning the Server object in a function in a non
> web environment - a regular class:
> string decodedText = System.Web.HttpContext.Current.Server.HtmlDecode(
> text );
> where the text property sometimes contains the char ř
> Is there some way that I can tell the HtmlDecode which encoding to use?
> /Jonas
> "Karl Seguin" <karl REMOVE @. REMOVE openmymind REMOVEMETOO . ANDME net>
> wrote in message news:%23o0ElR1lFHA.3552@.TK2MSFTNGP10.phx.gbl...
>
Yes the encoding is set ut utf-8
the strange thing is that the decodedText property still contains the
"ř" string after HtmlDecode
Nevermind, thanks for your explanation of the HtmlDecode, I have now created
a SpecialDecode function instead that works fine
private static string SpecialDecode(string decodedText)
{
string tmpResult = decodedText;
bool found = true;
try
{
while(found)
{
if( tmpResult.IndexOf("") > -1 )
{
string chars = tmpResult.Substring( tmpResult.IndexOf("")+2, 3);
//decode
char c1 = (char) ((ushort) int.Parse(chars));
tmpResult = tmpResult.Replace("" + chars + ";", c1.ToString());
}
else
{
found = false;
}
}
}
catch{}
return tmpResult;
}
"Karl Seguin" <karl REMOVE @. REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:e2uGEB2lFHA.3936@.TK2MSFTNGP10.phx.gbl...
>i don't think that's your problem (although within a class, there's no
>reason not to use System.Web.HttpUtility.HtmlDecode which decouples your
>class from the context (ie, it can be reused outside of the web)).
> All HtmlDecode does in the case of a numeric value (such as 345), is:
> char c1 = (char) ((ushort) int.Parse("345"));
> Response.Write(c1);
> Is your page encoding set to utf-8? (if you put tracing on, at the top of
> the trace information it says the encoding).l
> Karl
>
> --
> MY ASP.Net tutorials
> http://www.openmymind.net/ - New and Improved (yes, the popup is
> annoying)
> http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
> come!)
> "Jonas kermark" <jonas@.wipcore.se> wrote in message
> news:OELxjb1lFHA.2904@.TK2MSFTNGP14.phx.gbl...
>
Karl Seguin wrote:
> This works fine for me:
> Response.Write(Server.HtmlDecode("ř"));
> My web.config specifies:
> <globalization requestEncoding="utf-8" responseEncoding="utf-8" />
> maybe yours is using something else?
> Karl
Numeric references are based on Unicode code points, thus
requestEncoding and responseEncoding don't apply.
Cheers,
--
http://www.joergjooss.de
mailto:news-reply@.joergjooss.de
Server.HTMLDecode doesnt decode char 345
I have a problem decoding the czech character:
r
The HTML code for this character is ř but when running
Server.HTMLdecode on that string it just returns ř instead of the real
char. (It works on a lot of other characters)
I need to decode this string in order to render an image with this character
as a part of a headline.
Can anyone help me with this issue, or is it maybe a bug?
/kindest regards, JonasThis works fine for me:
Response.Write(Server.HtmlDecode("ř"));
My web.config specifies:
<globalization requestEncoding="utf-8" responseEncoding="utf-8" /
maybe yours is using something else?
Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Jonas kermark" <jonas@.wipcore.se> wrote in message
news:uY3DJazlFHA.2080@.TK2MSFTNGP14.phx.gbl...
> Hello!
> I have a problem decoding the czech character:
> r
> The HTML code for this character is ř but when running
> Server.HTMLdecode on that string it just returns ř instead of the
> real char. (It works on a lot of other characters)
> I need to decode this string in order to render an image with this
> character as a part of a headline.
> Can anyone help me with this issue, or is it maybe a bug?
> /kindest regards, Jonas
Maybe it is because I'm usning the Server object in a function in a non web
environment - a regular class:
string decodedText = System.Web.HttpContext.Current.Server.HtmlDecode(
text );
where the text property sometimes contains the char ř
Is there some way that I can tell the HtmlDecode which encoding to use?
/Jonas
"Karl Seguin" <karl REMOVE @. REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:%23o0ElR1lFHA.3552@.TK2MSFTNGP10.phx.gbl...
> This works fine for me:
> Response.Write(Server.HtmlDecode("ř"));
> My web.config specifies:
> <globalization requestEncoding="utf-8" responseEncoding="utf-8" />
> maybe yours is using something else?
> Karl
> --
> MY ASP.Net tutorials
> http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
> http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
> come!)
>
> "Jonas kermark" <jonas@.wipcore.se> wrote in message
> news:uY3DJazlFHA.2080@.TK2MSFTNGP14.phx.gbl...
>> Hello!
>>
>> I have a problem decoding the czech character:
>> r
>>
>> The HTML code for this character is ř but when running
>> Server.HTMLdecode on that string it just returns ř instead of the
>> real char. (It works on a lot of other characters)
>> I need to decode this string in order to render an image with this
>> character as a part of a headline.
>>
>> Can anyone help me with this issue, or is it maybe a bug?
>>
>> /kindest regards, Jonas
>>
i don't think that's your problem (although within a class, there's no
reason not to use System.Web.HttpUtility.HtmlDecode which decouples your
class from the context (ie, it can be reused outside of the web)).
All HtmlDecode does in the case of a numeric value (such as 345), is:
char c1 = (char) ((ushort) int.Parse("345"));
Response.Write(c1);
Is your page encoding set to utf-8? (if you put tracing on, at the top of
the trace information it says the encoding).l
Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Jonas kermark" <jonas@.wipcore.se> wrote in message
news:OELxjb1lFHA.2904@.TK2MSFTNGP14.phx.gbl...
> Maybe it is because I'm usning the Server object in a function in a non
> web environment - a regular class:
> string decodedText = System.Web.HttpContext.Current.Server.HtmlDecode(
> text );
> where the text property sometimes contains the char ř
> Is there some way that I can tell the HtmlDecode which encoding to use?
> /Jonas
> "Karl Seguin" <karl REMOVE @. REMOVE openmymind REMOVEMETOO . ANDME net>
> wrote in message news:%23o0ElR1lFHA.3552@.TK2MSFTNGP10.phx.gbl...
>> This works fine for me:
>> Response.Write(Server.HtmlDecode("ř"));
>>
>> My web.config specifies:
>> <globalization requestEncoding="utf-8" responseEncoding="utf-8" />
>>
>> maybe yours is using something else?
>>
>> Karl
>>
>> --
>> MY ASP.Net tutorials
>> http://www.openmymind.net/ - New and Improved (yes, the popup is
>> annoying)
>> http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
>> come!)
>>
>>
>> "Jonas kermark" <jonas@.wipcore.se> wrote in message
>> news:uY3DJazlFHA.2080@.TK2MSFTNGP14.phx.gbl...
>>> Hello!
>>>
>>> I have a problem decoding the czech character:
>>> r
>>>
>>> The HTML code for this character is ř but when running
>>> Server.HTMLdecode on that string it just returns ř instead of the
>>> real char. (It works on a lot of other characters)
>>> I need to decode this string in order to render an image with this
>>> character as a part of a headline.
>>>
>>> Can anyone help me with this issue, or is it maybe a bug?
>>>
>>> /kindest regards, Jonas
>>>
>>
>>
Yes the encoding is set ut utf-8
the strange thing is that the decodedText property still contains the
"ř" string after HtmlDecode
Nevermind, thanks for your explanation of the HtmlDecode, I have now created
a SpecialDecode function instead that works fine
private static string SpecialDecode(string decodedText)
{
string tmpResult = decodedText;
bool found = true;
try
{
while(found)
{
if( tmpResult.IndexOf("") > -1 )
{
string chars = tmpResult.Substring( tmpResult.IndexOf("")+2, 3);
//decode
char c1 = (char) ((ushort) int.Parse(chars));
tmpResult = tmpResult.Replace("" + chars + ";", c1.ToString());
}
else
{
found = false;
}
}
}
catch{}
return tmpResult;
}
"Karl Seguin" <karl REMOVE @. REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:e2uGEB2lFHA.3936@.TK2MSFTNGP10.phx.gbl...
>i don't think that's your problem (although within a class, there's no
>reason not to use System.Web.HttpUtility.HtmlDecode which decouples your
>class from the context (ie, it can be reused outside of the web)).
> All HtmlDecode does in the case of a numeric value (such as 345), is:
> char c1 = (char) ((ushort) int.Parse("345"));
> Response.Write(c1);
> Is your page encoding set to utf-8? (if you put tracing on, at the top of
> the trace information it says the encoding).l
> Karl
>
> --
> MY ASP.Net tutorials
> http://www.openmymind.net/ - New and Improved (yes, the popup is
> annoying)
> http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
> come!)
> "Jonas kermark" <jonas@.wipcore.se> wrote in message
> news:OELxjb1lFHA.2904@.TK2MSFTNGP14.phx.gbl...
>> Maybe it is because I'm usning the Server object in a function in a non
>> web environment - a regular class:
>>
>> string decodedText = System.Web.HttpContext.Current.Server.HtmlDecode(
>> text );
>>
>> where the text property sometimes contains the char ř
>>
>> Is there some way that I can tell the HtmlDecode which encoding to use?
>>
>> /Jonas
>>
>> "Karl Seguin" <karl REMOVE @. REMOVE openmymind REMOVEMETOO . ANDME net>
>> wrote in message news:%23o0ElR1lFHA.3552@.TK2MSFTNGP10.phx.gbl...
>>> This works fine for me:
>>> Response.Write(Server.HtmlDecode("ř"));
>>>
>>> My web.config specifies:
>>> <globalization requestEncoding="utf-8" responseEncoding="utf-8" />
>>>
>>> maybe yours is using something else?
>>>
>>> Karl
>>>
>>> --
>>> MY ASP.Net tutorials
>>> http://www.openmymind.net/ - New and Improved (yes, the popup is
>>> annoying)
>>> http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
>>> come!)
>>>
>>>
>>> "Jonas kermark" <jonas@.wipcore.se> wrote in message
>>> news:uY3DJazlFHA.2080@.TK2MSFTNGP14.phx.gbl...
>>>> Hello!
>>>>
>>>> I have a problem decoding the czech character:
>>>> r
>>>>
>>>> The HTML code for this character is ř but when running
>>>> Server.HTMLdecode on that string it just returns ř instead of the
>>>> real char. (It works on a lot of other characters)
>>>> I need to decode this string in order to render an image with this
>>>> character as a part of a headline.
>>>>
>>>> Can anyone help me with this issue, or is it maybe a bug?
>>>>
>>>> /kindest regards, Jonas
>>>>
>>>
>>>
>>
>>
Karl Seguin wrote:
> This works fine for me:
> Response.Write(Server.HtmlDecode("ř"));
> My web.config specifies:
> <globalization requestEncoding="utf-8" responseEncoding="utf-8" />
> maybe yours is using something else?
> Karl
Numeric references are based on Unicode code points, thus
requestEncoding and responseEncoding don't apply.
Cheers,
--
http://www.joergjooss.de
mailto:news-reply@.joergjooss.de
Server.HtmlDecode("") does not work
knows how to decode this character?What to you mean by decode. It's not coded.
is an UTF-8 representation of the symbol.
You can use Decoder utf8Decoder = Encoding.UTF8.GetDecoder();
to work with it or convert to Unicode. But you will not fit it into ASCII
table.
George.
<emailmygroup@.gmail.comwrote in message
news:1190056632.339146.229850@.50g2000hsm.googlegro ups.com...
Quote:
Originally Posted by
>I am trying to decode character #; but it is not working. Anybody
knows how to decode this character?
>
what do mean by not working? it will creates a 1 char string with an
ascii value of 145 (which is unprintable)
-- bruce (sqlwork.com)
emailmygroup@.gmail.com wrote:
Quote:
Originally Posted by
I am trying to decode character #; but it is not working. Anybody
knows how to decode this character?
>
Asc(Server.HtmlDecode("")) ' Output = 63 = "?"
can anybody help me?
I *reaally* don't understand your question.
When I process Server.HTMLDecode("")
...what I get as a result is : '
See the sample at : http://asp.net.do/test/HTMLencode.aspx
It's the LAST label in the list, after %3f ...and the code is :
im txtenc2 as String = Server.HTMLDecode("")
lblMessage6.Text = txtenc2
It seems to render OK in that test. What is the problem you're seeing ?
Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
======================================
<emailmygroup@.gmail.comwrote in message news:1190125136.354524.283640@.57g2000hsv.googlegro ups.com...
Quote:
Originally Posted by
can anybody help me?
>
On Sep 18, 10:00 am, "Juan T. Llibre" <nomailrepl...@.nowhere.com>
wrote:
Quote:
Originally Posted by
I *reaally* don't understand your question.
>
When I process Server.HTMLDecode("")
>
...what I get as a result is : '
>
See the sample at :http://asp.net.do/test/HTMLencode.aspx
>
It's the LAST label in the list, after %3f ...and the code is :
>
im txtenc2 as String = Server.HTMLDecode("")
lblMessage6.Text = txtenc2
>
When I write Server.HTMLDecode("") output is as follows
Output: (not printable character so no output)
length of string: 1
Ascii value of character using Asc function: 63
Do I need to change any settings anywhere? In my web.config file
<globalization requestEncoding="utf-8" responseEncoding="utf-8" />
Thanks
Quote:
Originally Posted by
It seems to render OK in that test. What is the problem you're seeing ?
>
Juan T. Llibre, asp.net MVP
asp.net faq :http://asp.net.do/faq/
foros de asp.net, en espaol :http://asp.net.do/foros/
======================================
>
>
>
<emailmygr...@.gmail.comwrote in messagenews:1190125136.354524.283640@.57g2000hsv.go oglegroups.com...
Quote:
Originally Posted by
can anybody help me?- Hide quoted text -
>
- Show quoted text -
re:
!Do I need to change any settings anywhere? In my web.config file
!<globalization requestEncoding="utf-8" responseEncoding="utf-8" />
I'm using :
<globalization requestEncoding="iso-8859-1" responseEncoding="iso-8859-1" fileEncoding="iso-8859-1" />
Can you test with those settings...and post back the result ?
Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
======================================
<emailmygroup@.gmail.comwrote in message news:1190130213.219447.126300@.i13g2000prf.googlegr oups.com...
On Sep 18, 10:00 am, "Juan T. Llibre" <nomailrepl...@.nowhere.com>
wrote:
Quote:
Originally Posted by
I *reaally* don't understand your question.
>
When I process Server.HTMLDecode("")
>
...what I get as a result is : '
>
See the sample at :http://asp.net.do/test/HTMLencode.aspx
>
It's the LAST label in the list, after %3f ...and the code is :
>
im txtenc2 as String = Server.HTMLDecode("")
lblMessage6.Text = txtenc2
>
When I write Server.HTMLDecode("") output is as follows
Output: (not printable character so no output)
length of string: 1
Ascii value of character using Asc function: 63
Do I need to change any settings anywhere? In my web.config file
<globalization requestEncoding="utf-8" responseEncoding="utf-8" />
Thanks
Quote:
Originally Posted by
It seems to render OK in that test. What is the problem you're seeing ?
>
Juan T. Llibre, asp.net MVP
asp.net faq :http://asp.net.do/faq/
foros de asp.net, en espaol :http://asp.net.do/foros/
======================================
>
>
>
<emailmygr...@.gmail.comwrote in messagenews:1190125136.354524.283640@.57g2000hsv.go oglegroups.com...
Quote:
Originally Posted by
can anybody help me?- Hide quoted text -
>
- Show quoted text -
I changed web.config as following
<globalization requestEncoding="iso-8859-1"
responseEncoding="iso-8859-1" fileEncoding="iso-8859-1" />
but no luck.