From ea2eed85b6afedcf37443a4953bade0186b9aef2 Mon Sep 17 00:00:00 2001 From: andi Date: Sat, 11 Jun 2005 11:29:16 +0200 Subject: spellchecker fixes for Konqeror Konqeror seems to ignore the charset darcs-hash:20050611092916-9977f-311b99e63b66a83c9f9022c468ba61d0687822c2.gz --- inc/html.php | 8 ++++---- inc/template.php | 10 +++++----- inc/utf8.php | 29 ++++++++++++++++++++++++++++- 3 files changed, 37 insertions(+), 10 deletions(-) (limited to 'inc') diff --git a/inc/html.php b/inc/html.php index a9135e155..9ec6049ef 100644 --- a/inc/html.php +++ b/inc/html.php @@ -277,7 +277,7 @@ function html_search(){ //show progressbar print '
'; - print ''; print '
'; @@ -317,7 +317,7 @@ function html_search(){ } //hide progressbar - print ''; } @@ -846,7 +846,7 @@ function html_edit($text=null,$include='edit'){ //FIXME: include needed? - ',$it); // load the default JavaScript files - ptln('',$it); - ptln('',$it); - ptln('',$it); // load spellchecker script if wanted if($conf['spellchecker'] && ($ACT=='edit' || $ACT=='preview')){ - ptln('',$it); } diff --git a/inc/utf8.php b/inc/utf8.php index 70b16f1a5..7d0f0a266 100644 --- a/inc/utf8.php +++ b/inc/utf8.php @@ -190,7 +190,7 @@ function utf8_ltrim($str,$charlist=''){ } /** - * Unicode aware replacement for ltrim() + * Unicode aware replacement for rtrim() * * @author Andreas Gohr * @see rtrim() @@ -341,6 +341,33 @@ function utf8_strpos($haystack, $needle,$offset=0) { } } +/** + * Encodes UTF-8 characters to HTML entities + * + * @author + * @link http://www.php.net/manual/en/function.utf8-decode.php + */ +function utf8_tohtml ($str) { + $ret = ''; + $max = strlen($str); + $last = 0; // keeps the index of the last regular character + for ($i=0; $i<$max; $i++) { + $c = $str{$i}; + $c1 = ord($c); + if ($c1>>5 == 6) { // 110x xxxx, 110 prefix for 2 bytes unicode + $ret .= substr($str, $last, $i-$last); // append all the regular characters we've passed + $c1 &= 31; // remove the 3 bit two bytes prefix + $c2 = ord($str{++$i}); // the next byte + $c2 &= 63; // remove the 2 bit trailing byte prefix + $c2 |= (($c1 & 3) << 6); // last 2 bits of c1 become first 2 of c2 + $c1 >>= 2; // c1 shifts 2 to the right + $ret .= '&#' . ($c1 * 100 + $c2) . ';'; // this is the fastest string concatenation + $last = $i+1; + } + } + return $ret . substr($str, $last, $i); // append the last batch of regular characters +} + /** * This function returns any UTF-8 encoded text as a list of * Unicode values: -- cgit v1.2.3