-1

Here is my code, which works fine, but it displays only hexadecimals:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
  <HEAD>
    <TITLE> New Document </TITLE>
    <META http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <SCRIPT LANGUAGE="JavaScript">
      function myfun() {
        var a= document.getElementById('anils').value;
        document.getElementById('anils2').value = "\u0C39\u0C48";
      }
    </SCRIPT>
  </HEAD>
  <BODY>
    <INPUT TYPE="text" NAME="anil" id="anils" />
    <INPUT TYPE="text" NAME="anil2" id="anils2" />
    <INPUT TYPE="button" id = "anils1" onclick="myfun()" />
  </BODY>
</HTML>

\u0C39\u0C48 is in hexadecimal but the equivalent decimal \u3129\u3144 is not displaying in my browser.

dda
  • 6,030
  • 2
  • 25
  • 34
AnilHoney
  • 259
  • 8
  • 20

2 Answers2

2

\u0C39 is not an HTML entity. HTML entities are used in HTML context and look like &...;. Valid HTML entities for the U+0C39 character (హ) include &#3129; (decimal) and &#xc39; (hexadecimal).

\u0C39 is a JavaScript Unicode escape sequence and has no relation to HTML. The format is exactly that, \u plus a four-digit hexadecimal number that represents the Unicode code-point. Period. Any other format you might try simply does not exist.

P.S. \u3129 represents U+3129 (ㄩ).

Álvaro González
  • 142,137
  • 41
  • 261
  • 360
  • హైదరాబాద్ go to this [link](http://www.online-toolz.com/tools/unicode-html-entities-convertor.php) and give above entities y got some unicode how to display that in text box(unicode) – AnilHoney Jun 12 '13 at 14:22
  • i have text in text box(హైదరాబాద్) i entered telugu language characters that went to server హైదరాబాద్ in this format now i want to save this database and i want to display this entities back to format that what i entered first(హైదరాబాద్) how to do that – AnilHoney Jun 12 '13 at 14:28
  • Just retrieve the values from the database and output them back into the HTML document (i.e. using `echo` for PHP) – rink.attendant.6 Jun 12 '13 at 14:38
  • @AnilHoney - There's absolutely no need to use HTML entities that way if your site is using UTF-8. [Are you using UTF-8 correctly?](http://stackoverflow.com/questions/279170/utf-8-all-the-way-through) – Álvaro González Jun 12 '13 at 14:42
  • please can u show me directely that by using html and javascript like entere హైదరాబాద్ text in one text box and show it another text box – AnilHoney Jun 12 '13 at 14:45
1

From comments - this is no longer anything to do with the question as stated. Suggest update the question to match your actual problem.

i have text in text box(హైదరాబాద్) i entered telugu language characters that went to server &#3129;&#3144;&#3110;&#3120;&#3134;&#3116;&#3134;&#3110;&#3149;

It sounds like your page is served without a specified encoding. Consequently the browser guesses what encoding to use to display it, and that encoding is probably not UTF-8.

When the browser submits the form, it uses the encoding of the web page. If that encoding isn't UTF-8 and so can't include the Telugu characters, the browser panics and tries sending the characters encoded as HTML character references instead. This is not a recoverable encoding, because you can't tell whether the character references are supposed to represent Unicode characters, or the user just deliberately typed &#...;.

To fix, ensure you include a Content-Type: text/html;charset=utf-8 HTTP header with the form's HTML page, or include the equivalent <meta charset> tag in the page HTML.

bobince
  • 528,062
  • 107
  • 651
  • 834