473,320 Members | 1,900 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,320 software developers and data experts.

ASP converts Unicode Chars to HTML entities?

Hello

i have following problem with ASP (using Interdev, Win2003 Server): if a
special character is entered in a textbox, ASP or the Client Browser (IE 6)
seems to convert this character in HTML entities.
eg characters on this site:
http://unicode.e-workers.de/kyrillisch.php

come back as eg &#1051 . i'm not shure, where exactly this happens. it
doesn't happen on ASP.NET sites though. the top of those documents looks
like this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="de" >
<head>
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf8">
<title>Beorda AG - Account Detail</title>
</head>
......
does anybody know how to avoid this? basically i'll need a utf8 postback i
guess. or i convert the entities to unicode before storing the values in the
database.

thanks for your hints

beat
Sep 5 '05 #1
2 12882


Beat Richli wrote:

i have following problem with ASP (using Interdev, Win2003 Server): if a
special character is entered in a textbox, ASP or the Client Browser (IE 6)
seems to convert this character in HTML entities.
eg characters on this site:
http://unicode.e-workers.de/kyrillisch.php

come back as eg &#1051 . i'm not shure, where exactly this happens.


Browsers have a tendency to do that if encodings are not properly
declared and have to be guessed or even if an encoding is properly
declared but characters the user enters are not representable in the
declared encoding. See
<http://ppewww.ph.gla.ac.uk/~flavell/charset/form-i18n.html>
If for instance your HTML document is encoded as ISO-8859-1 and then a
user enters the character "Л" in a form then browsers indeed pass that
on as %26%231051%3B which ASP would then decode as %26 for the character
'&', %23 for the character '#', the unencoded sequence of digits 1051
and as %3B as the character ';' which ends up as the string
'Л'
in your ASP Request.Form or Request.QueryString.

Thus one way to make sure the browser submits a properly encoded
character and not an encoded HTML character reference is to author the
HTML documents in the encoding UTF-8 and declare that properly, e.g. at
least with a
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
in the head of the document or even better by having the HTTP server
configured to send the HTTP response header
Content-Type: text/html; charset=UTF-8
That way the browser will then for instance encode the entered 'Л' as
'%D0%9B'.

ASP pages can also be authored using UTF-8 by using and indicating the
corresponding code page 65001 e.g.
<%@ Language="VBScript" CodePage="65001" %>

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Sep 7 '05 #2

"Martin Honnen" <ma*******@yahoo.de> schrieb im Newsbeitrag
news:O4**************@tk2msftngp13.phx.gbl...


Beat Richli wrote:

i have following problem with ASP (using Interdev, Win2003 Server): if a
special character is entered in a textbox, ASP or the Client Browser (IE
6) seems to convert this character in HTML entities.
eg characters on this site:
http://unicode.e-workers.de/kyrillisch.php

come back as eg &#1051 . i'm not shure, where exactly this happens.


Browsers have a tendency to do that if encodings are not properly declared
and have to be guessed or even if an encoding is properly declared but
characters the user enters are not representable in the declared encoding.
See
<http://ppewww.ph.gla.ac.uk/~flavell/charset/form-i18n.html>
If for instance your HTML document is encoded as ISO-8859-1 and then a
user enters the character "?" in a form then browsers indeed pass that on
as %26%231051%3B which ASP would then decode as %26 for the character '&',
%23 for the character '#', the unencoded sequence of digits 1051 and as
%3B as the character ';' which ends up as the string
'Л'
in your ASP Request.Form or Request.QueryString.

Thus one way to make sure the browser submits a properly encoded character
and not an encoded HTML character reference is to author the HTML
documents in the encoding UTF-8 and declare that properly, e.g. at least
with a
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
in the head of the document or even better by having the HTTP server
configured to send the HTTP response header
Content-Type: text/html; charset=UTF-8
That way the browser will then for instance encode the entered '?' as
'%D0%9B'.

ASP pages can also be authored using UTF-8 by using and indicating the
corresponding code page 65001 e.g.
<%@ Language="VBScript" CodePage="65001" %>

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/

thanks a lot Martin. i will check the site again using this information.

greets
beat
Sep 7 '05 #3

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

Similar topics

6
by: Horst Gutmann | last post by:
Hi :-) I currently have quite a big problem with minidom and special chars (for example &uuml;) in HTML. Let's say I have following input file:...
5
by: Nancy | last post by:
I recently completed a web page, "Browser Tests of Entities in 2004". http://www.santagata.us/characters/CharacterEntities.html It shows those characters that work in all of the version 5.2+...
3
by: hunterb | last post by:
I have a file which has no BOM and contains mostly single byte chars. There are numerous double byte chars (Japanese) which appear throughout. I need to take the resulting Unicode and store it in a...
7
by: Robert | last post by:
Hello, I'm using Pythonwin and py2.3 (py2.4). I did not come clear with this: I want to use win32-fuctions like win32ui.MessageBox, listctrl.InsertItem ..... to get unicode strings on the...
6
by: bruce | last post by:
hi... i'm running into a problem where i'm seeing non-ascii chars in the parsing i'm doing. in looking through various docs, i can't find functions to remove/restrict strings to valid ascii...
2
by: Frantic | last post by:
I'm working on a list of japaneese entities that contain the entity, the unicode hexadecimal code and the xml/sgml entity used for that entity. A unicode document is read into the program, then the...
3
by: Laangen_LU | last post by:
Dear Group, my first post to this group, so if I'm on the wrong group, my apologies. I'm trying to send out an email in Chinese lanuage using the mail() function in PHP. Subject and...
8
by: Steven D'Aprano | last post by:
I have a string containing Latin-1 characters: s = u"© and many more..." I want to convert it to HTML entities: result => "&copy; and many more..." Decimal/hex escapes would be...
6
by: Clodoaldo | last post by:
I was looking for a function to transform a unicode string into htmlentities. Not only the usual html escaping thing but all characters. As I didn't find I wrote my own: # -*- coding: utf-8...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.