SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    May 2003
    Location
    Houston
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to check if Japanese multibyte number is a num

    isNaN or valueOf returns NAN for a multibyte number.
    None of the javascript functions that I tried can determine
    if a japanese 2 is really a 2

    without converting each digit to unicode, then comparing
    to every digit from \uff10 to \uff19

    can anyone help?

  2. #2
    SitePoint Addict
    Join Date
    May 2000
    Posts
    313
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't know what a Japanese Multibyte number looks like, but it sounds like regular expressions will have to be used. Here are some links to tutorials on the subject:
    http://javascriptkit.com/javatutors/re.shtml
    http://javascriptkit.com/javatutors/re3.shtml
    http://javascriptkit.com/javatutors/re2.shtml
    http://javascriptkit.com/javatutors/re4.shtml

    Hope they help and good luck.

  3. #3
    SitePoint Member
    Join Date
    May 2003
    Location
    Houston
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    They don't help, any other suggestions?

  4. #4
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You shouldn't have to convert to unicode to use a pattern on it
    Code:
    function isJapNumber( num )
    {
    	return ( /^[\uff10-\uff19]+$/.test( num ) );
    }
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev





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
  •