×

Notice

The forum is in read only mode.
Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC: Special french characters

Special french characters 16 years 4 months ago #2251

  • djepy
  • djepy's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 3
  • Thank you received: 0
Hi,
I'm having pb with french accents, while testing JoomlaComment v4.0. Post is truncated at the first accented character.

Thx in advance.

Special french characters 16 years 4 months ago #2252

  • djepy
  • djepy's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 3
  • Thank you received: 0
I feel a bit stupid. I just discovered the component admin module... I'm sure I'll fine here the setting that will solve my pb (probably choosing the correct charset). So forget my previous post, I'll first have a look by myself and come back in case I'm not successful.

Special french characters 16 years 4 months ago #2253

  • Daniel Dimitrov
  • Daniel Dimitrov's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 9618
  • Karma: 155
  • Thank you received: 1081
Thanks for using 4.0 alpha and reporting the bugs in the forum.

go to components/com_comment/joscomment/utils.php

find following code
 function setMaxLength($text, $_maxlength_text)
    {
        if (($_maxlength_text != -1) && (strlen($text) > $_maxlength_text))
            $text = substr($text, 0, $_maxlength_text-3) . '...';
        return $text;
    }

change it to
    function setMaxLength($text, $_maxlength_text)
    {
        if (($_maxlength_text != -1) && (mb_strlen($text) > $_maxlength_text))
            $text = mb_substr($text, 0, $_maxlength_text-3) . '...';
        return $text;
    }
    function text_cut($str, $no_words_ret)
    {
 
	// $str est la cha�ne � couper
	// $no_words_ret est le nombre de mots qu'on souhaite en retour
 
	static $tags = array ('div', 'span', 'b', 'u', 'i', 'a', 'ul', 'li');
 
	$word_count = 0;
	$pos = 0;
	$str_len = strlen($str);
	$str .= ' <';
	$open_tags = array ();
 
	while ($word_count < $no_words_ret && $pos < $str_len) {
	    $pos = min(strpos($str, ' ', $pos), strpos($str, '<', $pos));
 
	    if ($str[$pos] == '<') {
		if ($str[$pos + 1] == '/') {
		    array_pop($open_tags);
		    $word_count++;
		} else {
		    $sub = substr($str, $pos + 1, min(strpos($str, ' ', $pos), strpos($str, '>', $pos)) - $pos - 1);
		    if (in_array($sub, $tags)) {
			array_push($open_tags, $sub);
		    }
		}
		$pos = strpos($str, '>', $pos) + 1;
	    } else {
		$pos++;
		$word_count++;
	    }
 
	}
 
	$str = substr($str, 0, $pos);
 
	if (count($open_tags) > 0) {
	    foreach($open_tags as $value) {
		$str .= '</' . array_pop($open_tags) . '>';
	    }
	}
 
	return($str);
    }
[code]
change to
 
[code]
  function text_cut($str, $no_words_ret)
    {
 
	// $str est la cha�ne � couper
	// $no_words_ret est le nombre de mots qu'on souhaite en retour
 
	static $tags = array ('div', 'span', 'b', 'u', 'i', 'a', 'ul', 'li');
 
	$word_count = 0;
	$pos = 0;
	$str_len = mb_strlen($str);
	$str .= ' <';
	$open_tags = array ();
 
	while ($word_count < $no_words_ret && $pos < $str_len) {
	    $pos = min(strpos($str, ' ', $pos), strpos($str, '<', $pos));
 
	    if ($str[$pos] == '<') {
		if ($str[$pos + 1] == '/') {
		    array_pop($open_tags);
		    $word_count++;
		} else {
		    $sub = mb_substr($str, $pos + 1, min(strpos($str, ' ', $pos), strpos($str, '>', $pos)) - $pos - 1);
		    if (in_array($sub, $tags)) {
			array_push($open_tags, $sub);
		    }
		}
		$pos = strpos($str, '>', $pos) + 1;
	    } else {
		$pos++;
		$word_count++;
	    }
 
	}
 
	$str = mb_substr($str, 0, $pos);
 
	if (count($open_tags) > 0) {
	    foreach($open_tags as $value) {
		$str .= '</' . array_pop($open_tags) . '>';
	    }
	}
 
	return($str);
    }

I believe that should be everything you need to make. Please tell us if it working :)

Special french characters 16 years 4 months ago #2254

  • djepy
  • djepy's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 3
  • Thank you received: 0
Thx Daniel. Unfortunately, it didn't work.
The solution is even simpler : I just added utf-8 in the charset settings, and now it works like a charm !

Cheers.

Special french characters 16 years 4 months ago #2255

  • Daniel Dimitrov
  • Daniel Dimitrov's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 9618
  • Karma: 155
  • Thank you received: 1081
LOL :)
  • Page:
  • 1
Time to create page: 0.189 seconds