function formulaires_configurer_transcodeur_verifier_dist() { include_spip('inc/charsets'); $erreurs = array(); if (!($charset = _request('charset'))) { $erreurs['charset'] = _T('info_obligatoire'); } elseif ($charset != 'utf-8' and !load_charset($charset)) { $erreurs['charset'] = _T('utf8_convert_erreur_orig', array('charset' => $charset)); } return $erreurs; }
function exec_convert_utf8_dist() { include_spip('inc/minipres'); include_spip('inc/charsets'); // Definir le titre de la page (et le nom du fichier admin) $action = _T('utf8_convertir_votre_site'); // si meta deja la, c'est une reprise apres timeout. if ($GLOBALS['meta']['convert_utf8'] AND $GLOBALS['meta']['admin']) { $admin = charger_fonction('admin', 'inc'); echo $admin('convert_utf8', $action, '', true); } else { $charset_orig = $GLOBALS['meta']['charset']; // tester si le charset d'origine est connu de spip if (!load_charset($charset_orig)) convert_utf8_non($action, _T('utf8_convert_erreur_orig', array('charset' => "<b>".$charset_orig."</b>"))); // ne pas convertir si deja utf8 // ou si l'interface du serveur ne comprend rien else if (($charset_orig == 'utf-8')) convert_utf8_non($action, _T('utf8_convert_erreur_deja', array('charset' => $charset_orig))); else if(!sql_get_charset('utf-8')) convert_utf8_non($action, _L('Votre version du serveur SQL ne gere pas les charset')); else { $commentaire = _T('utf8_convert_avertissement', array('orig' => $charset_orig,'charset' => 'utf-8')); $commentaire .= "<small>" . http_img_pack('warning.gif', _T('info_avertissement'), "style='width: 48px; height: 48px; float: right;margin: 10px;'"); $commentaire .= _T('utf8_convert_backup', array('charset' => 'utf-8')) ."</small>"; $commentaire .= '<br />'._T('utf8_convert_timeout'); $commentaire .= "<hr />\n"; $admin = charger_fonction('admin', 'inc'); echo $admin('convert_utf8', $action, $commentaire); } } }
function configuration_transcodeur_dist() { $charset = $GLOBALS['meta']["charset"]; $res = _T('texte_jeu_caractere') . "<blockquote class='spip'>\n<p>" . _T('texte_jeu_caractere_3') . "</p>\n<div style='text-align: center'><b><tt>" .entites_html($charset) ."</tt></b></div><p>" ."<label for='charset'>" ._T('texte_jeu_caractere_4') ."</label>" ." <input type='text' name='charset' id='charset' value=\"".entites_html($charset)."\" />" . "<br />\n(". _T('texte_jeu_caractere_2').")" . "</p></blockquote>\n"; // faudrait dire si le charset est inconnu // ca eviterait l'erreur sur array_flip dans inc/charsets if ($charset != 'utf-8' AND load_charset($charset)) $res .= _T('texte_jeu_caractere_conversion', array('url' => generer_url_ecrire('convert_utf8')) ); $res = ajax_action_post('configurer', 'transcodeur', 'config_lang', '', $res); $res = debut_cadre_relief("breve-24.gif", true, "", _T('info_jeu_caractere')) . $res . fin_cadre_relief(true); return ajax_action_greffe("configurer-transcodeur", '', $res); }
<?php /***************************************************************************\ * SPIP, Systeme de publication pour l'internet * * * * Copyright (c) 2001-2012 * * Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James * * * * Ce programme est un logiciel libre distribue sous licence GNU/GPL. * * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * \***************************************************************************/ if (!defined('_ECRIRE_INC_VERSION')) { return; } // arabic iso-8859-6 - http://czyborra.com/charsets/iso8859.html#ISO-8859-6 load_charset('iso-8859-1'); $trans = $GLOBALS['CHARSET']['iso-8859-1']; $mod = array(0xa0 => 0xa0, 0xa4 => 0xa4, 0xac => 0x60c, 0xad => 0xad, 0xbb => 0x61b, 0xbf => 0x61f, 0xc1 => 0x621, 0xc2 => 0x622, 0xc3 => 0x623, 0xc4 => 0x624, 0xc5 => 0x625, 0xc6 => 0x626, 0xc7 => 0x627, 0xc8 => 0x628, 0xc9 => 0x629, 0xca => 0x62a, 0xcb => 0x62b, 0xcc => 0x62c, 0xcd => 0x62d, 0xce => 0x62e, 0xcf => 0x62f, 0xd0 => 0x630, 0xd1 => 0x631, 0xd2 => 0x632, 0xd3 => 0x633, 0xd4 => 0x634, 0xd5 => 0x635, 0xd6 => 0x636, 0xd7 => 0x637, 0xd8 => 0x638, 0xd9 => 0x639, 0xda => 0x63a, 0xe0 => 0x640, 0xe1 => 0x641, 0xe2 => 0x642, 0xe3 => 0x643, 0xe4 => 0x644, 0xe5 => 0x645, 0xe6 => 0x646, 0xe7 => 0x647, 0xe8 => 0x648, 0xe9 => 0x649, 0xea => 0x64a, 0xeb => 0x64b, 0xec => 0x64c, 0xed => 0x64d, 0xee => 0x64e, 0xef => 0x64f, 0xf0 => 0x650, 0xf1 => 0x651, 0xf2 => 0x652); foreach ($mod as $num => $val) { $trans[$num] = $val; } $GLOBALS['CHARSET']['iso-8859-6'] = $trans;
<?php /***************************************************************************\ * SPIP, Systeme de publication pour l'internet * * * * Copyright (c) 2001-2016 * * Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James * * * * Ce programme est un logiciel libre distribue sous licence GNU/GPL. * * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * \***************************************************************************/ /** * Déclaration pour la translitteration complexe des correspondances entre * caractères unicodes spécifiques et caractères simples la plage ASCII * * Ajoute des caractères supplémentaires à la déclaration de translitteration simple * * @package SPIP\Core\Charsets **/ if (!defined('_ECRIRE_INC_VERSION')) { return; } load_charset('translit'); $trans = $GLOBALS['CHARSET']['translit']; $translit_c = array(225 => "a'", 224 => "a`", 7843 => "a?", 227 => "a~", 7841 => "a.", 226 => "a^", 7845 => "a^'", 7847 => "a^`", 7849 => "a^?", 7851 => "a^~", 7853 => "a^.", 259 => "a(", 7855 => "a('", 7857 => "a(`", 7859 => "a(?", 7861 => "a(~", 7863 => "a(.", 193 => "A'", 192 => "A`", 7842 => "A?", 195 => "A~", 7840 => "A.", 194 => "A^", 7844 => "A^'", 7846 => "A^`", 7848 => "A^?", 7850 => "A^~", 7852 => "A^.", 258 => "A(", 7854 => "A('", 7856 => "A(`", 7858 => "A(?", 7860 => "A(~", 7862 => "A(.", 233 => "e'", 232 => "e`", 7867 => "e?", 7869 => "e~", 7865 => "e.", 234 => "e^", 7871 => "e^'", 7873 => "e^`", 7875 => "e^?", 7877 => "e^~", 7879 => "e^.", 201 => "E'", 200 => "E`", 7866 => "E?", 7868 => "E~", 7864 => "E.", 202 => "E^", 7870 => "E^'", 7872 => "E^`", 7874 => "E^?", 7876 => "E^~", 7878 => "E^.", 237 => "i'", 236 => "i`", 7881 => "i?", 297 => "i~", 7883 => "i.", 205 => "I'", 204 => "I`", 7880 => "I?", 296 => "I~", 7882 => "I.", 243 => "o'", 242 => "o`", 7887 => "o?", 245 => "o~", 7885 => "o.", 244 => "o^", 7889 => "o^'", 7891 => "o^`", 7893 => "o^?", 7895 => "o^~", 7897 => "o^.", 417 => "o+", 7899 => "o+'", 7901 => "o+`", 7903 => "o+?", 7905 => "o+~", 7907 => "o+.", 211 => "O'", 210 => "O`", 7886 => "O?", 213 => "O~", 7884 => "O.", 212 => "O^", 7888 => "O^'", 7890 => "O^`", 7892 => "O^?", 7894 => "O^~", 7896 => "O^.", 416 => "O+", 7898 => "O+'", 7900 => "O+`", 7902 => "O+?", 7904 => "O+~", 7906 => "O+.", 250 => "u'", 249 => "u`", 7911 => "u?", 361 => "u~", 7909 => "u.", 432 => "u+", 7913 => "u+'", 7915 => "u+`", 7917 => "u+?", 7919 => "u+~", 7921 => "u+.", 218 => "U'", 217 => "U`", 7910 => "U?", 360 => "U~", 7908 => "U.", 431 => "U+", 7912 => "U+'", 7914 => "U+`", 7916 => "U+?", 7918 => "U+~", 7920 => "U+.", 253 => "y'", 7923 => "y`", 7927 => "y?", 7929 => "y~", 7925 => "y.", 221 => "Y'", 7922 => "Y`", 7926 => "Y?", 7928 => "Y~", 7924 => "Y.", 273 => "d-", 208 => "D-", 228 => 'ae', 246 => 'oe', 252 => 'ue', 196 => 'Ae', 214 => 'Oe', 220 => 'Ue'); foreach ($translit_c as $u => $t) { $trans[$u] = $t; } $GLOBALS['CHARSET']['translitcomplexe'] = $trans;
function translitteration_rapide($texte, $charset='AUTO', $complexe='') { static $trans; if ($charset == 'AUTO') $charset = $GLOBALS['meta']['charset']; if (!strlen($texte)) return $texte; $table_translit ='translit'.$complexe; // 2. Translitterer grace a la table predefinie if (!$trans[$complexe]) { global $CHARSET; load_charset($table_translit); foreach ($CHARSET[$table_translit] as $key => $val) $trans[$complexe][caractere_utf_8($key)] = $val; } return str_replace(array_keys($trans[$complexe]),array_values($trans[$complexe]),$texte); }
function translitteration($texte, $charset = 'AUTO', $complexe = '') { static $trans; if ($charset == 'AUTO') { $charset = read_meta('charset'); } $charset = strtolower($charset); $table_translit = 'translit' . $complexe; // 1. Passer le charset et les é en utf-8 $texte = unicode_to_utf_8(html2unicode(charset2unicode($texte, $charset, true))); // 2. Translitterer grace a la table predefinie if (!$trans[$complexe]) { global $CHARSET; load_charset($table_translit); reset($CHARSET[$table_translit]); while (list($key, $val) = each($CHARSET[$table_translit])) { $trans[$complexe][caractere_utf_8($key)] = $val; } } if ($GLOBALS['flag_strtr2']) { $texte = strtr($texte, $trans[$complexe]); } else { $tr = $trans[$complexe]; while (list($from, $to) = each($tr)) { $texte = str_replace($from, $to, $texte); } } /* // Le probleme d'iconv c'est qu'il risque de nous renvoyer des ? alors qu'on // prefere garder l'utf-8 pour que la chaine soit indexable. // 3. Translitterer grace a iconv if ($GLOBALS['flag_iconv'] && preg_match('/�*([0-9]+);/', $texte)) { $texte = iconv('utf-8', 'ascii//translit', $texte); } */ return $texte; }