com web/news: Encode error message to UTF-8 and set iso-8859-1 as default "IN CHARSET": common.php
| From: | Ben Ramsey | Date: | Tue, 18 Jul 2017 17:27:47 +0000 |
| Subject: | com web/news: Encode error message to UTF-8 and set iso-8859-1 as default "IN CHARSET": common.php | ||
| Groups: | php.webmaster | ||
| Request: | Send a blank email to php-webmaster+get-26165@lists.php.net to get a copy of this message | ||
Commit: 9548552bd4374ac7d1f0d7cadfd13e1ffc1f2990
Author: Arnaud Lemercier <arnaud@wixiweb.fr> Tue, 18 Jul 2017 19:27:47 +0200
Parents: 2912428f238670ac9d1359ea4ea2bebaa70d17b1
Branches: master
Link: http://git.php.net/?p=web/news.git;a=commitdiff;h=9548552bd4374ac7d1f0d7cadfd13e1ffc1f2990
Log:
Encode error message to UTF-8 and set iso-8859-1 as default "IN CHARSET"
Changed paths:
M common.php
Diff:
diff --git a/common.php b/common.php
index f18443d..50ffa3f 100644
--- a/common.php
+++ b/common.php
@@ -12,7 +12,7 @@ define('NNTP_HOST', $NNTP_HOST);
function error($str) {
head("PHP news : error");
- echo "<blockquote><strong>Error:</strong> $str</blockquote>\n";
+ echo "<blockquote><strong>Error:</strong>
".to_utf8($str)."</blockquote>\n";
foot();
die();
}
@@ -54,9 +54,9 @@ function foot() {?>
<?php
}
-function to_utf8($str, $charset)
+function to_utf8($str, $charset = 'iso-8859-1')
{
- $n = iconv($charset ? $charset : 'iso-8859-1', 'utf-8', $str);
+ $n = iconv($charset , 'utf-8', $str);
if ($n === false) {
return $str;
}