FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » FUDforum Development » Plugins and Code Hacks » about chinese search
Show: Today's Messages :: Unread Messages :: Show Polls :: Message Navigator
| Subscribe to topic | Bookmark topic 
Switch to threaded view of this topic Create a new topic Submit Reply
about chinese search [message #35975] Mon, 26 February 2007 05:08
debozh is currently offline  debozh   China
Messages: 2
Registered: February 2007
Karma: 0
Junior Member
add to buddy list
ignore all messages by this user
function mb_word_split($str, $lang)
{
	$m = array();

	switch ($lang) {
		case 'chinese_big5':
			preg_match_all('!((?:[A-Za-z]+) | (?:[\xa1-\xfe] [\x40-\x7e] | [\xa1-\xfe] ) )!xs', $str, $m);
			break;
		case 'chinese': /* bg2312 */
			preg_match_all('!((?:[A-Za-z]+) | (?:[\xa1-\xf7] [\xa1-\xfe] ) | ( [\xa1-\xfe] [\x40-\x7e] | [\xa1-\xfe] ) )!xs', $str, $m);
			break;
		case 'japanese': /* utf-8 */
		case 'korean':
			preg_match_all('!((?:[\x0-\x7f]+) | (?:[\xc0-\xfd]{1}[\x80-\xbf]+) )!xs', $str, $m);
			break;
	}

	if (!$m) {
		return array();
	}

	$m2 = array();
	$tmp="";
	foreach (array_unique($m[0]) as $v) {
		if (isset($v[1])) 
		{
			if(preg_match('!(?:[A-Za-z]+)!xs',$v))
			{
				$m2[] = _esc($v);
			}
			else
			{
				if($tmp!="")
				{
					$m2[] = _esc($tmp.$v);
				}
				$tmp=$v;
			}
		}
	}
	return $m2;
}

[Updated on: Wed, 28 February 2007 07:33]

Report message to a moderator

Quick Reply
Formatting Tools:   
  Switch to threaded view of this topic Create a new topic
Previous Topic: NNTP Mime type addition
Next Topic: Members link to profiles in Group Manager
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Oct 20 17:50:13 EDT 2017

Total time taken to generate the page: 0.00643 seconds