Announcement

  •  » Engine
  •  » [resolved] IPTC encoding windows-1252 Vs iso-8859-1

#1 2013-09-09 11:48:34

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13791

[resolved] IPTC encoding windows-1252 Vs iso-8859-1

Hi,

In include/functions_metadata.inc.php we assume that if we find non ASCII characters and if string doesn't qualify as UTF-8 then we apply a iso-8859-1 to utf-8 conversion.

A user has reported a problem with symbol "oe" (as a single character, ie "ligature") : the string is not displayed in Piwigo, but still exists (as an invisible character).

I have tried to replace iso-8859-1 by windows-1252 in function clean_iptc_value and it works fine on this photo. Then I wondered if you could detect Windows-1252 or ISO-8859-1 but it doesn't work with mb_detect_encoding. Then I read on http://stackoverflow.com/questions/3714 … 1-to-utf-8 :

[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.

That means that if you use windows-1252 as origin encoding for conversion instead of iso-8859-1 it should be good for both windows-1252 and iso-8859-1 strings.

Do you think it's OK for changing:

Code:

[pierrick@pierrick-desktop] ~/public_html/piwigo/dev/branches/2.5                                                                                                                                                                                                                      
$ svn diff include/
Index: include/functions_metadata.inc.php
===================================================================
--- include/functions_metadata.inc.php  (revision 23497)
+++ include/functions_metadata.inc.php  (working copy)
@@ -103,7 +103,7 @@
     if ( ($qual = qualify_utf8($value)) != 0)
     {// has non ascii chars
       $value = convert_charset( $value,
-        $qual>0 ? 'utf-8' : 'iso-8859-1',
+        $qual>0 ? 'utf-8' : 'windows-1252',
         get_pwg_charset() );
     }
   }

Offline

 

#2 2013-09-10 09:39:26

rvelices
Former Piwigo Team
2005-12-29
1960

Re: [resolved] IPTC encoding windows-1252 Vs iso-8859-1

ok with the condition iconv or mb_convert_encoding functions exist ...

Offline

 

#3 2013-09-10 09:45:11

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13791

Re: [resolved] IPTC encoding windows-1252 Vs iso-8859-1

Hi rvelices,

rvelices wrote:

ok with the condition iconv or mb_convert_encoding functions exist ...

Can you be more explicit?

Offline

 

#4 2013-09-10 09:53:10

rvelices
Former Piwigo Team
2005-12-29
1960

Re: [resolved] IPTC encoding windows-1252 Vs iso-8859-1

plg wrote:

Hi rvelices,

rvelices wrote:

ok with the condition iconv or mb_convert_encoding functions exist ...

Can you be more explicit?

Take a look at convert_charset function

Code:

  if ($source_charset==$dest_charset)
    return $str;
  if ($source_charset=='iso-8859-1' and $dest_charset=='utf-8')
  {
    return utf8_encode($str);
  }
  if ($source_charset=='utf-8' and $dest_charset=='iso-8859-1')
  {
    return utf8_decode($str);
  }
  if (function_exists('iconv'))
  {
    return iconv($source_charset, $dest_charset, $str);
  }
  if (function_exists('mb_convert_encoding'))
  {
    return mb_convert_encoding( $str, $dest_charset, $source_charset );
  }
  return $str; //???

Offline

 

#5 2013-10-17 22:12:50

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13791

Re: [resolved] IPTC encoding windows-1252 Vs iso-8859-1

OK, done [Subversion] r24967, thank you rvelices.

Offline

 

#6 2015-02-18 14:43:51

bocman
Member
2015-02-18
42

Re: [resolved] IPTC encoding windows-1252 Vs iso-8859-1

Hello!
I have last version of Piwigo, but I have a problem with encoding IPTC.
In attachment 2 files:
goog_iptc.jpg have data in UTF-8
bed_iptc.jpg have data in ASCII win1251

goog_iptc.jpg is showed normally in Piwigo, but bed_iptc.jpg is showed uncorrect

Offline

 

#7 2015-02-18 14:56:07

flop25
Piwigo Team
2006-07-06
7037

Re: [resolved] IPTC encoding windows-1252 Vs iso-8859-1

hello
check the metadata using tool/metadata.php and report us in new thread Thx


To get a better help : Politeness like Hello-A link-Your past actions precisely described
Check my extensions : more than 30 available
who I am and what I do : http://fr.gravatar.com/flop25
My gallery : an illustration of how to integrate Piwigo in your website

Offline

 
  •  » Engine
  •  » [resolved] IPTC encoding windows-1252 Vs iso-8859-1

Board footer

Powered by FluxBB

github twitter newsletter Donate Piwigo.org © 2002-2024 · Contact