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

Home » FUDforum Development » Plugins and Code Hacks » about chinese search
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
about chinese search [message #35975] Mon, 26 February 2007 10:08
debozh is currently offline  debozh   China
Messages: 2
Registered: February 2007
Karma:
Junior Member
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 12:33]

Report message to a moderator

[Message index]
 
Read Message
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: Sun Nov 24 07:37:36 GMT 2024

Total time taken to generate the page: 0.05854 seconds