SitePoint Sponsor |
|
User Tag List
Results 1 to 6 of 6
Thread: getting ASCII code
-
Sep 21, 2007, 00:25 #1
- Join Date
- Sep 2007
- Location
- Islamabad, Pakistan
- Posts
- 101
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
getting ASCII code
Hi All,
Is there anyway we can get any character's ASCII code.Zia Awan
-
Sep 21, 2007, 00:39 #2
- Join Date
- Nov 2004
- Location
- Ankh-Morpork
- Posts
- 12,158
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Code JavaScript:var hi = "Hi"; alert(hi.charCodeAt(0)); // Shows '72'
Birnam wood is come to Dunsinane
-
Sep 21, 2007, 01:24 #3
- Join Date
- Jun 2004
- Location
- Copenhagen, Denmark
- Posts
- 6,157
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Strictly speaking, that's not an ASCII code, unless you give it a character in the 0-127 range. charCodeAt() returns the unicode codepoint (Which incidentally is a superset of ISO-8859-1, if I'm not mistaken). Try this:
Code:alert("闻".charCodeAt(0));
-
Sep 21, 2007, 02:53 #4
- Join Date
- Sep 2007
- Location
- Islamabad, Pakistan
- Posts
- 101
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Thank you guys for your replies. Could you please tell me what is the difference between Unicode and ASCII code?
Zia Awan
-
Sep 21, 2007, 02:56 #5
- Join Date
- Nov 2004
- Location
- Ankh-Morpork
- Posts
- 12,158
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
ASCII is a subset of Unicode. See The Definitive Guide to Web Character Encoding for details.
Birnam wood is come to Dunsinane
-
Sep 21, 2007, 03:10 #6
- Join Date
- Sep 2007
- Location
- Islamabad, Pakistan
- Posts
- 101
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Thank you very much for your reply, it looks like a nice article.
Zia Awan
Bookmarks