With "DHTML Form with xCode" when I write a letter with accent and I click on "Preview", the text is not displayed.
The problem is related to the fact that if the input string contains an invalid code unit sequence within the given encoding an empty string will be returned.
See: http://php.net/manual/en/function.htmlspecialchars.php
The problem is that XOOPS check everything as UTF-8, and therefore will see the ISO-8859-1 codes as "invalid codes" and will return empty string.
Therefore check if the encoding is European ISO-8859-1, and if yes, don't use UTF-8.
To fix it, in /class/module.textsanitizer replace the line 518:
$text = $this->htmlSpecialChars($text);
with
if (mb_detect_encoding($text , 'ISO-8859-1', true)){ $text = $this->htmlSpecialChars($text,ENT_QUOTES ,'ISO-8859-1'); } else { $text = $this->htmlSpecialChars($text); }
Could you describe more precisely the case ? As everything is UTF8, how could it be possible to have iso-8859-1 strings ?
Which one is better or more correct? (1-mamba solution or 2-alain01 solution proposed in mail) :
in /class/module.textsanitizer replace the line 518:
1-mamba solution:
or
2-alain01 solution:
if ($html != 1) { // html not allowed $text = mb_convert_encoding($text, 'UTF-8', mb_detect_encoding($text,'UTF-8, ISO-8859-1', true)); $text = $this->htmlSpecialChars($text,ENT_COMPAT,'UTF-8'); }
According to montuy337513 (black_beard on xoops.org), mamba's solution consumes fewer resources.
Log in to post a comment.
The problem is related to the fact that if the input string contains an invalid code unit sequence within the given encoding an empty string will be returned.
See: http://php.net/manual/en/function.htmlspecialchars.php
The problem is that XOOPS check everything as UTF-8, and therefore will see the ISO-8859-1 codes as "invalid codes" and will return empty string.
Therefore check if the encoding is European ISO-8859-1, and if yes, don't use UTF-8.
To fix it, in /class/module.textsanitizer replace the line 518:
$text = $this->htmlSpecialChars($text);
with
if (mb_detect_encoding($text , 'ISO-8859-1', true)){
$text = $this->htmlSpecialChars($text,ENT_QUOTES ,'ISO-8859-1');
}
else {
$text = $this->htmlSpecialChars($text);
}
Could you describe more precisely the case ? As everything is UTF8, how could it be possible to have iso-8859-1 strings ?
Which one is better or more correct? (1-mamba solution or 2-alain01 solution proposed in mail) :
in /class/module.textsanitizer replace the line 518:
$text = $this->htmlSpecialChars($text);
with
1-mamba solution:
if (mb_detect_encoding($text , 'ISO-8859-1', true)){
$text = $this->htmlSpecialChars($text,ENT_QUOTES ,'ISO-8859-1');
}
else {
$text = $this->htmlSpecialChars($text);
}
or
2-alain01 solution:
if ($html != 1) {
// html not allowed
$text = mb_convert_encoding($text, 'UTF-8', mb_detect_encoding($text,'UTF-8, ISO-8859-1', true));
$text = $this->htmlSpecialChars($text,ENT_COMPAT,'UTF-8');
}
Last edit: Cesag 2013-02-26
According to montuy337513 (black_beard on xoops.org), mamba's solution consumes fewer resources.