Rev | Line | |
---|
[9005] | 1 | <?php |
---|
| 2 | /* |
---|
| 3 | Plugin Name: IPTC from Mac |
---|
| 4 | Version: auto |
---|
| 5 | Description: Convert IPTC written in MacRoman encoding into UTF8 |
---|
| 6 | Plugin URI: http://piwigo.org/ext/extension_view.php?eid= |
---|
| 7 | Author: plg |
---|
| 8 | Author URI: http://piwigo.wordpress.com |
---|
| 9 | */ |
---|
| 10 | |
---|
| 11 | if (!defined('PHPWG_ROOT_PATH')) |
---|
| 12 | { |
---|
| 13 | die('Hacking attempt!'); |
---|
| 14 | } |
---|
| 15 | |
---|
| 16 | add_event_handler('clean_iptc_value', 'MacRoman_to_utf8'); |
---|
| 17 | function MacRoman_to_utf8($str, $break_ligatures='none') |
---|
| 18 | { |
---|
| 19 | // $break_ligatures : 'none' | 'fifl' | 'all' |
---|
| 20 | // 'none' : don't break any MacRoman ligatures, transform them into their utf-8 counterparts |
---|
| 21 | // 'fifl' : break only fi ("\xDE" => "fi") and fl ("\xDF"=>"fl") |
---|
| 22 | // 'all' : break fi, fl and also AE ("\xAE"=>"AE"), ae ("\xBE"=>"ae"), OE ("\xCE"=>"OE") and oe ("\xCF"=>"oe") |
---|
| 23 | |
---|
| 24 | if($break_ligatures == 'fifl') |
---|
| 25 | { |
---|
| 26 | $str = strtr($str, array("\xDE"=>"fi", "\xDF"=>"fl")); |
---|
| 27 | } |
---|
| 28 | |
---|
| 29 | if($break_ligatures == 'all') |
---|
| 30 | { |
---|
| 31 | $str = strtr($str, array("\xDE"=>"fi", "\xDF"=>"fl", "\xAE"=>"AE", "\xBE"=>"ae", "\xCE"=>"OE", "\xCF"=>"oe")); |
---|
| 32 | } |
---|
| 33 | |
---|
| 34 | $str = strtr( |
---|
| 35 | $str, |
---|
| 36 | array( |
---|
| 37 | "\x7F"=>"\x20", |
---|
| 38 | "\x80"=>"\xC3\x84", |
---|
| 39 | "\x81"=>"\xC3\x85", |
---|
| 40 | "\x82"=>"\xC3\x87", |
---|
| 41 | "\x83"=>"\xC3\x89", |
---|
| 42 | "\x84"=>"\xC3\x91", |
---|
| 43 | "\x85"=>"\xC3\x96", |
---|
| 44 | "\x86"=>"\xC3\x9C", |
---|
| 45 | "\x87"=>"\xC3\xA1", |
---|
| 46 | "\x88"=>"\xC3\xA0", |
---|
| 47 | "\x89"=>"\xC3\xA2", |
---|
| 48 | "\x8A"=>"\xC3\xA4", |
---|
| 49 | "\x8B"=>"\xC3\xA3", |
---|
| 50 | "\x8C"=>"\xC3\xA5", |
---|
| 51 | "\x8D"=>"\xC3\xA7", |
---|
| 52 | "\x8E"=>"\xC3\xA9", |
---|
| 53 | "\x8F"=>"\xC3\xA8", |
---|
| 54 | "\x90"=>"\xC3\xAA", |
---|
| 55 | "\x91"=>"\xC3\xAB", |
---|
| 56 | "\x92"=>"\xC3\xAD", |
---|
| 57 | "\x93"=>"\xC3\xAC", |
---|
| 58 | "\x94"=>"\xC3\xAE", |
---|
| 59 | "\x95"=>"\xC3\xAF", |
---|
| 60 | "\x96"=>"\xC3\xB1", |
---|
| 61 | "\x97"=>"\xC3\xB3", |
---|
| 62 | "\x98"=>"\xC3\xB2", |
---|
| 63 | "\x99"=>"\xC3\xB4", |
---|
| 64 | "\x9A"=>"\xC3\xB6", |
---|
| 65 | "\x9B"=>"\xC3\xB5", |
---|
| 66 | "\x9C"=>"\xC3\xBA", |
---|
| 67 | "\x9D"=>"\xC3\xB9", |
---|
| 68 | "\x9E"=>"\xC3\xBB", |
---|
| 69 | "\x9F"=>"\xC3\xBC", |
---|
| 70 | "\xA0"=>"\xE2\x80\xA0", |
---|
| 71 | "\xA1"=>"\xC2\xB0", |
---|
| 72 | "\xA2"=>"\xC2\xA2", |
---|
| 73 | "\xA3"=>"\xC2\xA3", |
---|
| 74 | "\xA4"=>"\xC2\xA7", |
---|
| 75 | "\xA5"=>"\xE2\x80\xA2", |
---|
| 76 | "\xA6"=>"\xC2\xB6", |
---|
| 77 | "\xA7"=>"\xC3\x9F", |
---|
| 78 | "\xA8"=>"\xC2\xAE", |
---|
| 79 | "\xA9"=>"\xC2\xA9", |
---|
| 80 | "\xAA"=>"\xE2\x84\xA2", |
---|
| 81 | "\xAB"=>"\xC2\xB4", |
---|
| 82 | "\xAC"=>"\xC2\xA8", |
---|
| 83 | "\xAD"=>"\xE2\x89\xA0", |
---|
| 84 | "\xAE"=>"\xC3\x86", |
---|
| 85 | "\xAF"=>"\xC3\x98", |
---|
| 86 | "\xB0"=>"\xE2\x88\x9E", |
---|
| 87 | "\xB1"=>"\xC2\xB1", |
---|
| 88 | "\xB2"=>"\xE2\x89\xA4", |
---|
| 89 | "\xB3"=>"\xE2\x89\xA5", |
---|
| 90 | "\xB4"=>"\xC2\xA5", |
---|
| 91 | "\xB5"=>"\xC2\xB5", |
---|
| 92 | "\xB6"=>"\xE2\x88\x82", |
---|
| 93 | "\xB7"=>"\xE2\x88\x91", |
---|
| 94 | "\xB8"=>"\xE2\x88\x8F", |
---|
| 95 | "\xB9"=>"\xCF\x80", |
---|
| 96 | "\xBA"=>"\xE2\x88\xAB", |
---|
| 97 | "\xBB"=>"\xC2\xAA", |
---|
| 98 | "\xBC"=>"\xC2\xBA", |
---|
| 99 | "\xBD"=>"\xCE\xA9", |
---|
| 100 | "\xBE"=>"\xE6", |
---|
| 101 | "\xBF"=>"\xC3\xB8", |
---|
| 102 | "\xC0"=>"\xC2\xBF", |
---|
| 103 | "\xC1"=>"\xC2\xA1", |
---|
| 104 | "\xC2"=>"\xC2\xAC", |
---|
| 105 | "\xC3"=>"\xE2\x88\x9A", |
---|
| 106 | "\xC4"=>"\xC6\x92", |
---|
| 107 | "\xC5"=>"\xE2\x89\x88", |
---|
| 108 | "\xC6"=>"\xE2\x88\x86", |
---|
| 109 | "\xC7"=>"\xC2\xAB", |
---|
| 110 | "\xC8"=>"\xC2\xBB", |
---|
| 111 | "\xC9"=>"\xE2\x80\xA6", |
---|
| 112 | "\xCA"=>"\xC2\xA0", |
---|
| 113 | "\xCB"=>"\xC3\x80", |
---|
| 114 | "\xCC"=>"\xC3\x83", |
---|
| 115 | "\xCD"=>"\xC3\x95", |
---|
| 116 | "\xCE"=>"\xC5\x92", |
---|
| 117 | "\xCF"=>"\xC5\x93", |
---|
| 118 | "\xD0"=>"\xE2\x80\x93", |
---|
| 119 | "\xD1"=>"\xE2\x80\x94", |
---|
| 120 | "\xD2"=>"\xE2\x80\x9C", |
---|
| 121 | "\xD3"=>"\xE2\x80\x9D", |
---|
| 122 | "\xD4"=>"\xE2\x80\x98", |
---|
| 123 | "\xD5"=>"\xE2\x80\x99", |
---|
| 124 | "\xD6"=>"\xC3\xB7", |
---|
| 125 | "\xD7"=>"\xE2\x97\x8A", |
---|
| 126 | "\xD8"=>"\xC3\xBF", |
---|
| 127 | "\xD9"=>"\xC5\xB8", |
---|
| 128 | "\xDA"=>"\xE2\x81\x84", |
---|
| 129 | "\xDB"=>"\xE2\x82\xAC", |
---|
| 130 | "\xDC"=>"\xE2\x80\xB9", |
---|
| 131 | "\xDD"=>"\xE2\x80\xBA", |
---|
| 132 | "\xDE"=>"\xEF\xAC\x81", |
---|
| 133 | "\xDF"=>"\xEF\xAC\x82", |
---|
| 134 | "\xE0"=>"\xE2\x80\xA1", |
---|
| 135 | "\xE1"=>"\xC2\xB7", |
---|
| 136 | "\xE2"=>"\xE2\x80\x9A", |
---|
| 137 | "\xE3"=>"\xE2\x80\x9E", |
---|
| 138 | "\xE4"=>"\xE2\x80\xB0", |
---|
| 139 | "\xE5"=>"\xC3\x82", |
---|
| 140 | "\xE6"=>"\xC3\x8A", |
---|
| 141 | "\xE7"=>"\xC3\x81", |
---|
| 142 | "\xE8"=>"\xC3\x8B", |
---|
| 143 | "\xE9"=>"\xC3\x88", |
---|
| 144 | "\xEA"=>"\xC3\x8D", |
---|
| 145 | "\xEB"=>"\xC3\x8E", |
---|
| 146 | "\xEC"=>"\xC3\x8F", |
---|
| 147 | "\xED"=>"\xC3\x8C", |
---|
| 148 | "\xEE"=>"\xC3\x93", |
---|
| 149 | "\xEF"=>"\xC3\x94", |
---|
| 150 | "\xF0"=>"\xEF\xA3\xBF", |
---|
| 151 | "\xF1"=>"\xC3\x92", |
---|
| 152 | "\xF2"=>"\xC3\x9A", |
---|
| 153 | "\xF3"=>"\xC3\x9B", |
---|
| 154 | "\xF4"=>"\xC3\x99", |
---|
| 155 | "\xF5"=>"\xC4\xB1", |
---|
| 156 | "\xF6"=>"\xCB\x86", |
---|
| 157 | "\xF7"=>"\xCB\x9C", |
---|
| 158 | "\xF8"=>"\xC2\xAF", |
---|
| 159 | "\xF9"=>"\xCB\x98", |
---|
| 160 | "\xFA"=>"\xCB\x99", |
---|
| 161 | "\xFB"=>"\xCB\x9A", |
---|
| 162 | "\xFC"=>"\xC2\xB8", |
---|
| 163 | "\xFD"=>"\xCB\x9D", |
---|
| 164 | "\xFE"=>"\xCB\x9B", |
---|
| 165 | "\xFF"=>"\xCB\x87", |
---|
| 166 | "\x00"=>"\x20", |
---|
| 167 | "\x01"=>"\x20", |
---|
| 168 | "\x02"=>"\x20", |
---|
| 169 | "\x03"=>"\x20", |
---|
| 170 | "\x04"=>"\x20", |
---|
| 171 | "\x05"=>"\x20", |
---|
| 172 | "\x06"=>"\x20", |
---|
| 173 | "\x07"=>"\x20", |
---|
| 174 | "\x08"=>"\x20", |
---|
| 175 | "\x0B"=>"\x20", |
---|
| 176 | "\x0C"=>"\x20", |
---|
| 177 | "\x0E"=>"\x20", |
---|
| 178 | "\x0F"=>"\x20", |
---|
| 179 | "\x10"=>"\x20", |
---|
| 180 | "\x11"=>"\x20", |
---|
| 181 | "\x12"=>"\x20", |
---|
| 182 | "\x13"=>"\x20", |
---|
| 183 | "\x14"=>"\x20", |
---|
| 184 | "\x15"=>"\x20", |
---|
| 185 | "\x16"=>"\x20", |
---|
| 186 | "\x17"=>"\x20", |
---|
| 187 | "\x18"=>"\x20", |
---|
| 188 | "\x19"=>"\x20", |
---|
| 189 | "\x1A"=>"\x20", |
---|
| 190 | "\x1B"=>"\x20", |
---|
| 191 | "\x1C"=>"\x20", |
---|
| 192 | "\1D"=>"\x20", |
---|
| 193 | "\x1E"=>"\x20", |
---|
| 194 | "\x1F"=>"\x20", |
---|
| 195 | "\xF0"=>"" |
---|
| 196 | ) |
---|
| 197 | ); |
---|
| 198 | |
---|
| 199 | return $str; |
---|
| 200 | } |
---|
| 201 | ?> |
---|
Note: See
TracBrowser
for help on using the repository browser.