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;
	}