Hi,

As described in the Askeet project, I use URLs containing the title of
the pages. I strip the titles with the stripText($text) function found
here : http://www.symfony-project.org/askeet/1_0/4

I also have to replace diacritical chars with their corresponding
regular char (the website will be bilingual french/english). I've
tried everything I could think about, but the information stored in
the DB is not ok : the field in the DB contains a string truncated at
the first diacritical char.

The fixture file is stored in UTF-8 format, and the unstripped title
is correctly saved to the DB. Therefore, I conclude that my problem is
to replace diacitical chars in and UTF-8 text.

Anyone has an idea?

Thank to all
Guy

PS : Here below are all the things I've tried so far :

            $patterns = array('/à/', '/á/', '/â/', '/ã/', '/ä/', '/
å/', '/
ò/', '/ó/',
                              '/ô/', '/õ/', '/ö/', '/ø/', '/è/', '/
é/', '/
ê/', '/ë/',
                              '/ç/', '/ì/', '/í/', '/î/', '/ï/', '/
ù/', '/
ú/', '/û/',
                              '/ü/', '/ÿ/', '/ñ/');

            $replace  = array('a', 'a', 'a', 'a', 'a', 'a', 'o', 'o',
                              'o', 'o', 'o', 'o', 'e', 'e', 'e', 'e',
                              'c', 'i', 'i', 'i', 'i', 'u', 'u', 'u',
                              'u', 'y', 'n');

            $text = preg_replace($patterns, $replace, $text);

=======================================

                $accent
=array('À','Á','Â','Ã','Ä','Å','Æ','Ç','È','É','Ê','Ë','Ì','Í','Î','Ï','Ð','Ñ','Ò','Ó','Ô','Õ','Ö','Ø','Ù','Ú','Û','Ü','Ý','Þ','ß','à','á','â','ã','ä','å','æ','ç','è','é','ê','ë','ì','í','î','ï','ð','ñ','ò','ó','ô','õ','ö','ø','ù','ú','û','ý','ý','þ','ÿ');

$noaccent=array('a','a','a','a','a','a','a','c','e','e','e','e','i','i','i','i','d','n','o','o','o','o','o','o','u','u','u','u','y','b','s','a','a','a','a','a','a','a','c','e','e','e','e','i','i','i','i','d','n','o','o','o','o','o','o','u','u','u','y','y','b','y');
            $text=str_replace($accent,$noaccent,$text);

=======================================

        static public function sanitizeText($text)
                {
                return preg_replace('/[^a-z0-9_\.-]/i', '_', $text);
                }

=======================================

        static public function urlize($url)
                {
                $search = array('/[^a-z0-9]/', '/--+/', '/^-+/', '/-+
$/' );
                $replace = array( '-', '-', '', '');
                return preg_replace($search, $replace,
utf2ascii($url));
                }

=======================================

        static public function utf2ascii($string)
                {
                $iso88591  = "\\xE0\\xE1\\xE2\\xE3\\xE4\\xE5\\xE6\
\xE7";
                $iso88591 .= "\\xE8\\xE9\\xEA\\xEB\\xEC\\xED\\xEE\
\xEF";
                $iso88591 .= "\\xF0\\xF1\\xF2\\xF3\\xF4\\xF5\\xF6\
\xF7";
                $iso88591 .= "\\xF8\\xF9\\xFA\\xFB\\xFC\\xFD\\xFE\
\xFF";
                $ascii = "aaaaaaaceeeeiiiidnooooooouuuuyyy";
                return strtr(mb_strtolower(utf8_decode($string),
'ISO-8859-1'),
$iso88591,$ascii);
                }

=======================================

        static public function CleanDiacrText($text)
                {
                $text = strtr($text,
'ÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿ',
'AAAAAACEEEEIIIIOOOOOUUUUYaaaaaaceeeeiiiioooooouuuuyy');
                return $text;
                }
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to