SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Zealot xiaawan's Avatar
    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

  2. #2
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,159
    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

  3. #3
    SitePoint Wizard silver trophy kyberfabrikken's Avatar
    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));

  4. #4
    SitePoint Zealot xiaawan's Avatar
    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

  5. #5
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,159
    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

  6. #6
    SitePoint Zealot xiaawan's Avatar
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •