+ return (bool)preg_match( '/[\x80-\xff]/', $str );
+ }
+
+ function ucwords($str) {
+ if ( self::isMultibyte( $str ) ) {
+ $str = self::lc($str);
+
+ // regexp to find first letter in each word (i.e. after each space)
+ $replaceRegexp = "/^([a-z]|[\\xc0-\\xff][\\x80-\\xbf]*)| ([a-z]|[\\xc0-\\xff][\\x80-\\xbf]*)/";
+
+ // function to use to capitalize a single char
+ if ( function_exists( 'mb_strtoupper' ) )
+ return preg_replace_callback(
+ $replaceRegexp,
+ array($this,"ucwordsCallbackMB"),
+ $str
+ );
+ else
+ return preg_replace_callback(
+ $replaceRegexp,
+ array($this,"ucwordsCallbackWiki"),
+ $str
+ );
+ }
+ else
+ return ucwords( strtolower( $str ) );
+ }
+
+ # capitalize words at word breaks
+ function ucwordbreaks($str){
+ if (self::isMultibyte( $str ) ) {
+ $str = self::lc($str);
+
+ // since \b doesn't work for UTF-8, we explicitely define word break chars
+ $breaks= "[ \-\(\)\}\{\.,\?!]";
+
+ // find first letter after word break
+ $replaceRegexp = "/^([a-z]|[\\xc0-\\xff][\\x80-\\xbf]*)|$breaks([a-z]|[\\xc0-\\xff][\\x80-\\xbf]*)/";
+
+ if ( function_exists( 'mb_strtoupper' ) )
+ return preg_replace_callback(
+ $replaceRegexp,
+ array($this,"ucwordbreaksCallbackMB"),
+ $str
+ );
+ else
+ return preg_replace_callback(
+ $replaceRegexp,
+ array($this,"ucwordsCallbackWiki"),
+ $str
+ );
+ }
+ else
+ return preg_replace_callback(
+ '/\b([\w\x80-\xff]+)\b/',
+ array($this,"ucwordbreaksCallbackAscii"),
+ $str );
+ }
+
+ /**
+ * Return a case-folded representation of $s
+ *
+ * This is a representation such that caseFold($s1)==caseFold($s2) if $s1
+ * and $s2 are the same except for the case of their characters. It is not
+ * necessary for the value returned to make sense when displayed.
+ *
+ * Do *not* perform any other normalisation in this function. If a caller
+ * uses this function when it should be using a more general normalisation
+ * function, then fix the caller.
+ */
+ function caseFold( $s ) {
+ return $this->uc( $s );