From 9af9c0a2c5ce4233659895f0420efa43b8b480d2 Mon Sep 17 00:00:00 2001 From: tokul Date: Sun, 27 Jul 2003 10:38:38 +0000 Subject: [PATCH] Added cleanup_nbsp function. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@5438 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- functions/i18n.php | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/functions/i18n.php b/functions/i18n.php index cbf4e54a..76d22910 100644 --- a/functions/i18n.php +++ b/functions/i18n.php @@ -697,4 +697,50 @@ function korean_charset_xtra() { return $ret; } +/* + * This function can be used to replace non-braking space symbols + * that are inserted in forms by some browsers instead of normal + * space symbol. + */ +function cleanup_nbsp($string,$charset) { + + // reduce number of case statements + if (stristr('iso-8859-',substr($charset,0,9))){ + $output_charset="iso-8859-x"; + } + if (stristr('windows-125',substr($charset,0,11))){ + $output_charset="cp125x"; + } + if (stristr('koi8',substr($charset,0,4))){ + $output_charset="koi8-x"; + } + if (! isset($output_charset)){ + $output_charset=strtolower($charset); + } + +// where is non-braking space symbol +switch($output_charset): + case "iso-8859-x": + $nbsp="\xA0"; + break; + case "cp125x": + $nbsp="\xA0"; + break; + case "koi8-x": + $nbsp="\x9A"; + break; + case "utf-8": + $nbsp="\xC2\xA0"; + break; + case "iso-2022-jp": + $nbsp="\xA0"; + break; + default: + // don't change string if charset is unmatched + return $string; +endswitch; + +// return space instead of non-braking space. + return str_replace($nbsp,' ',$string); +} ?> \ No newline at end of file -- 2.25.1