Webmaster Forum

Go Back   Webmaster Forum > Web Development > Coding Forum

Coding Forum Problems with your code? Discuss coding issues, including JavaScript, PHP & MySQL, HTML & CSS, Flash & ActionScript, and more.


Reply
 
Thread Tools Display Modes
Share |
  #1  
Old 12-09-2011, 02:54 PM
softgroups softgroups is offline
Contributing Member
 
Join Date: 07-15-06
Posts: 95
iTrader: 1 / 100%
PHP :Detecting if a string it's japaness/chiness ?!

I would like to know how i can may be able to detect non english native text like russian, japanese, chiness from a string?


For example:
https://mobile.twitter.com/TAIKO2000

IF you click view source, you will see that those "crazy laters" are just added there, they are not in that unicode format like & ; 0233 ...etc...

So how i can tell if a string it's using latin alphabet, and not japaness or chiness?
 
Reply With Quote

Advertisement

Advertisement

  #2  
Old 12-09-2011, 04:09 PM
J. H. Rasmussen J. H. Rasmussen is offline
Super Moderator
 
Join Date: 11-11-11
Location: Copenhagen, Denmark
Posts: 6,007
iTrader: 1 / 100%
I think you got it upsite down. If the website uses an unicode "charset" like UTF-8, UTF-16 etc., then it can have unicode characters without using "& ;", if it dose not use an unicode characterset, then you will need to use "& ;" to display unicode characters.

I believe that "& ;" was used a lot in the old days for countries like japan and china when not all web browsers supported unicode charactersets in webpages.

Quote:
Originally Posted by softgroups View Post
So how i can tell if a string it's using latin alphabet, and not japaness or chiness?
To many x'ses and Y'es in that line, maybe if the string is unicode you could test the characters index of the characterset and see if the index value is in the range where chineee, japanese etc. characters are located in the unicode characterset. Maybe it would be easier to help if you told us what programming language you use? eg. php, perl, c, c++ etc.
 
Reply With Quote
  #3  
Old 12-09-2011, 04:26 PM
softgroups softgroups is offline
Contributing Member
 
Join Date: 07-15-06
Posts: 95
iTrader: 1 / 100%
Yup, i am going to use

Code:
function check_chiness($data){ $iadevar=0; $xlogic1=strlen($data); $data2=utf8_decode($data); $xlogic2=strlen($data2); $xlogic=$xlogic1-$xlogic2; if($xlogic>=50){$iadevar=1;} return $iadevar; }
 
Reply With Quote
  #4  
Old 12-09-2011, 05:23 PM
J. H. Rasmussen J. H. Rasmussen is offline
Super Moderator
 
Join Date: 11-11-11
Location: Copenhagen, Denmark
Posts: 6,007
iTrader: 1 / 100%
Looks like there is a good example here:
PHP Code:
$str "This is a string containing 中文 characters. Some more characters - 中华人民共和国 ";

preg_match(/[\x{4e00}-\x{9fa5}]+.*\-/u$str$matches); 
Source: http://stackoverflow.com/questions/1...-in-the-string

Last edited by J. H. Rasmussen; 12-09-2011 at 05:47 PM.
 
Reply With Quote
  #5  
Old 12-10-2011, 10:36 PM
ExpertsGuide ExpertsGuide is offline
Junior Member
 
Join Date: 11-25-11
Location: India
Posts: 22
iTrader: 0 / 0%
Quote:
Originally Posted by J. H. Rasmussen View Post
Looks like there is a good example here:
PHP Code:
$str "This is a string containing 中文 characters. Some more characters - 中华人民共和国 ";

preg_match(/[\x{4e00}-\x{9fa5}]+.*\-/u$str$matches); 
Source: http://stackoverflow.com/questions/1...-in-the-string
The only thing missing is single quote around the regex.
 
Reply With Quote
Go Back   Webmaster Forum > Web Development > Coding Forum

Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help in detecting phones mimo91 Coding Forum 1 08-11-2011 01:05 AM
Detecting Googlebombs Cricket Google Forum 6 02-10-2009 01:54 AM
Detecting fake PR jumpenjuhosaphat Google Forum 8 12-29-2006 01:33 PM
Detecting all backlinks (PR1, 2, 3, 4, 5 ...) Tariel Zivzivadze Google Forum 11 06-26-2004 12:39 AM


V7N Network
Get exposure! V7N I Love Photography V7N SEO Blog V7N Directory


All times are GMT -7. The time now is 03:50 PM.
Powered by vBulletin
Copyright 2000-2014 Jelsoft Enterprises Limited.
Copyright © 2003 - 2018 VIX-WomensForum LLC