Package util;
Public class ischineseorenglish {
/**
* Create Date: 2009-2-10 Author: Administrator
*
* @ Param ARGs
*/
// General_punctuation
// Cjk_symbols_and_punctuation judge Chinese characters. No.
// Halfwidth_and_fullwidth_forms indicates the number of Chinese characters.
Public static Boolean ischinese (char c ){
Character. unicodeblock UB = character. unicodeblock. of (c );
If (UB = character. unicodeblock. cjk_uniied_ideographs
| UB = character. unicodeblock. cjk_compatibility_ideographs
| UB = character. unicodeblock. cjk_uniied_ideographs_extension_a
| UB = character. unicodeblock. general_punctuation
| UB = character. unicodeblock. cjk_symbols_and_punctuation
| UB = character. unicodeblock. halfwidth_and_fullwidth_forms ){
Return true;
}
Return false;
}
/**
*
* Create Date: 2009-2-10 Author: Administrator
* Determines whether a string contains Chinese characters.
* @ Param strname
*/
Public static Boolean ischinese (string strname ){
Char [] CH = strname. tochararray ();
For (INT I = 0; I <Ch. length; I ++ ){
Char c = CH [I];
If (ischinese (c) = true ){
Return true;
}
}
Return false;
}
Public static void main (string [] ARGs ){
//
// Random r = new random ();
//
// For (INT I = 0; I <20; I ++)
//
// System. Out. println (R. nextint (10) + 1 );
// Ischinese ("English ");
System. Out. println (ischinese ('you '));
System. Out. println (ischinese ("DSF -- 8 $ DSF "));
}
}