Re: Browser Converts No ASCII for JS Text Node or any Text Attribute



On Jun 29, 12:01 pm, Martin Honnen <mahotr...@xxxxxxxx> wrote:
vunet...@xxxxxxxxx wrote:
Browsers convert my ASCII fine when webpage is set to
charset=iso-8859-1.
However, my AJAX app has too many cases with

var myASCII = "&#x00FC;";
document.createTextNode(myASCII);

In this case or similar, such as option.text = myASCII; for select
object, browsers fail to convert ASCII to HTML.

The createTextNode method takes a DOM string, in JavaScript that is
simply a JavaScript string so try
document.createTextNode("ü")
or
document.createTextNode(String.fromCharCode(0xFC))
or
document.createTextNode("\u00FC")

The &#x00FC; syntax is a numeric character reference meant for an HTML
or XML parser. createTextNode does not do any HTML or XML parsing.

--

Martin Honnen
http://JavaScript.FAQTs.com/

Yes, Unicode works well: document.createTextNode("\u00FC"). However,
my strings look like:

var myASCII = "Do not remove text &#x00FC; and do not remove text,
blah blah";
document.createTextNode(myASCII);

and there are plenty of different strings containing all possible
ASCII values. What would you recommend in that case. Is it possible to
convert all ASCII to Unicode, then?

.



Relevant Pages

  • JavaMail - Insert some html from a file
    ... I'm developing some code that uses the JavaMail API to send an email. ... I'd like the body to contain HTML, ... with the setContentmethod that accepts a string, ... ascii, not UTF-8. ...
    (comp.lang.java.help)
  • Re: JavaMail - Insert some html from a file
    ... > I'm developing some code that uses the JavaMail API to send an email. ... > I'd like the body to contain HTML, ... > with the setContentmethod that accepts a string, ... > ascii, not UTF-8. ...
    (comp.lang.java.help)
  • problem with mb_detect_encoding
    ... I am trying to determine if data entered in a $_POST variable in a form contains all ASCII characters or not. ... After thinking about it and running some tests I figured out that it is doing this because PHP is feeding mb_detect_encoding the string after it is converted to its html ...
    (comp.lang.php)
  • Re: getAttribute question
    ... oddity with IE that getAttributereturns an empty string if the ... HTML specification, ... appropriate places in the HTML 4 and DOM HTML specifications. ...
    (comp.lang.javascript)
  • Re: [PHP] generating an html intro text ...
    ... You would have to search out and pull in all closing tags. ... grab 256 characters -- The string. ... html markup should not go towards the string length count, ...
    (php.general)