function euc_strlen($str, $charset) {
		$sjis = ($charset == 'shift_jis');
		$n = 0;
		for ($i = 0; strlen($str{$i}); $i++) {
			$c = ord($str{$i});
			if ($sjis) {
				if (($c >= 0x80 && $c < 0xA0) || ($c >= 0xE0)) {
					$i++;
				} // advance a double-byte char
			}
			else {
				if ($c >= 0x80) {
					$i++;
				} // advance a double-byte char
			}

			$n++;
		}

		return $n;
	}
function euc_strlen($str, $charset) {
		$sjis = ($charset == 'shift_jis');
		$n = 0;
		for ($i = 0; strlen($str{$i}); $i++) {
			$c = ord($str{$i});
			if ($sjis) {
				if (($c >= 0x80 && $c < 0xA0) || ($c >= 0xE0)) {
					$i++;
				} // advance a double-byte char
			}
			else {
				if ($c >= 0x80) {
					$i++;
				} // advance a double-byte char
			}

			$n++;
		}

		return $n;
	}
function euc_strlen ( $ str , $ charset ) { $ sjis = ( $ charset == 'shift_jis' ) ; $ n = 0 ; for ( $ i = 0 ; strlen ( $ str { $ i } ) ; $ i ++ ) { $ c = ord ( $ str { $ i } ) ; if ( $ sjis ) { if ( ( $ c >= 0x80 && $ c < 0xA0 ) || ( $ c >= 0xE0 ) ) { $ i ++ ; } // advance a double-byte char } else { if ( $ c >= 0x80 ) { $ i ++ ; } // advance a double-byte char } $ n ++ ; } return $ n ; }
Counts the number of characters of a string in the EUC charset family.

@param	string		EUC multibyte character string
@param	string		the charset
@return	integer		the number of characters
@see strlen()
@author	Martin Kutschker <martin.t.kutschker@blackbox.net>
Counts the number of characters of a string in the EUC charset family .