aboutsummaryrefslogtreecommitdiffstats
path: root/include/functions_metadata.inc.php
diff options
context:
space:
mode:
authorplegall <plg@piwigo.org>2013-10-17 20:15:51 +0000
committerplegall <plg@piwigo.org>2013-10-17 20:15:51 +0000
commita397debf025bab70a7975e127c6bad6db5f6216b (patch)
treee31b2961c459c6f0b340da485596b68e1731969f /include/functions_metadata.inc.php
parent5abcfccff06f64ba3e7d273c0e5a3b6ec56d047c (diff)
merge r24967 from branch 2.5 to trunk
bug 2973 fixed: automatically use encoding windows-1252 instead of iso-8859-1 (unless we find utf-8 signs) on IPTC before converting to utf-8 git-svn-id: http://piwigo.org/svn/trunk@24968 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'include/functions_metadata.inc.php')
-rw-r--r--include/functions_metadata.inc.php22
1 files changed, 19 insertions, 3 deletions
diff --git a/include/functions_metadata.inc.php b/include/functions_metadata.inc.php
index 97724abc1..0727feb1e 100644
--- a/include/functions_metadata.inc.php
+++ b/include/functions_metadata.inc.php
@@ -102,9 +102,25 @@ function clean_iptc_value($value)
$value = trigger_event('clean_iptc_value', $value);
if ( ($qual = qualify_utf8($value)) != 0)
{// has non ascii chars
- $value = convert_charset( $value,
- $qual>0 ? 'utf-8' : 'iso-8859-1',
- get_pwg_charset() );
+ if ($qual>0)
+ {
+ $input_encoding = 'utf-8';
+ }
+ else
+ {
+ $input_encoding = 'iso-8859-1';
+ if (function_exists('iconv') or function_exists('mb_convert_encoding'))
+ {
+ // using windows-1252 because it supports additional characters
+ // such as "oe" in a single character (ligature). About the
+ // difference between Windows-1252 and ISO-8859-1: the characters
+ // 0x80-0x9F will not convert correctly. But these are control
+ // characters which are almost never used.
+ $input_encoding = 'windows-1252';
+ }
+ }
+
+ $value = convert_charset($value, $input_encoding, get_pwg_charset());
}
}
return $value;