function sb_char_mapping($str, $charset, $mode, $opt = '') {
		switch ($mode) {
			case 'case':
				if (!$this->initCaseFolding($charset)) {
					return $str;
				} // do nothing
				$map =& $this->caseFolding[$charset][$opt];
				break;

			case 'ascii':
				if (!$this->initToASCII($charset)) {
					return $str;
				} // do nothing
				$map =& $this->toASCII[$charset];
				break;

			default:
				return $str;
		}

		$out = '';
		for ($i = 0; strlen($str{$i}); $i++) {
			$c = $str{$i};
			if (isset($map[$c])) {
				$out .= $map[$c];
			} else {
				$out .= $c;
			}
		}

		return $out;
	}
function sb_char_mapping($str, $charset, $mode, $opt = '') {
		switch ($mode) {
			case 'case':
				if (!$this->initCaseFolding($charset)) {
					return $str;
				} // do nothing
				$map =& $this->caseFolding[$charset][$opt];
				break;

			case 'ascii':
				if (!$this->initToASCII($charset)) {
					return $str;
				} // do nothing
				$map =& $this->toASCII[$charset];
				break;

			default:
				return $str;
		}

		$out = '';
		for ($i = 0; strlen($str{$i}); $i++) {
			$c = $str{$i};
			if (isset($map[$c])) {
				$out .= $map[$c];
			} else {
				$out .= $c;
			}
		}

		return $out;
	}
function sb_char_mapping ( $ str , $ charset , $ mode , $ opt = '' ) { switch ( $ mode ) { case 'case' : if ( ! $ this -> initCaseFolding ( $ charset ) ) { return $ str ; } // do nothing $ map = & $ this -> caseFolding [ $ charset ] [ $ opt ] ; break ; case 'ascii' : if ( ! $ this -> initToASCII ( $ charset ) ) { return $ str ; } // do nothing $ map = & $ this -> toASCII [ $ charset ] ; break ; default : return $ str ; } $ out = '' ; for ( $ i = 0 ; strlen ( $ str { $ i } ) ; $ i ++ ) { $ c = $ str { $ i } ; if ( isset ( $ map [ $ c ] ) ) { $ out .= $ map [ $ c ] ; } else { $ out .= $ c ; } } return $ out ; }
Maps all characters of a string in a single byte charset.

@param	string		the string
@param	string		the charset
@param	string		mode: 'case' (case folding) or 'ascii' (ASCII transliteration)
@param	string		'case': conversion 'toLower' or 'toUpper'
@return	string		the converted string
@author	Martin Kutschker <martin.t.kutschker@blackbox.net>
Maps all characters of a string in a single byte charset .