Changeset 6947 for trunk


Ignore:
Timestamp:
Sep 16, 2010, 7:30:56 PM (14 years ago)
Author:
rvelices
Message:

remove_accents function improvement: shorter + faster code (less func calls)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/functions.inc.php

    r6944 r6947  
    243243    $chars = array(
    244244    // Decompositions for Latin-1 Supplement
    245     chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
    246     chr(195).chr(130) => 'A', chr(195).chr(131) => 'A',
    247     chr(195).chr(132) => 'A', chr(195).chr(133) => 'A',
    248     chr(195).chr(135) => 'C', chr(195).chr(136) => 'E',
    249     chr(195).chr(137) => 'E', chr(195).chr(138) => 'E',
    250     chr(195).chr(139) => 'E', chr(195).chr(140) => 'I',
    251     chr(195).chr(141) => 'I', chr(195).chr(142) => 'I',
    252     chr(195).chr(143) => 'I', chr(195).chr(145) => 'N',
    253     chr(195).chr(146) => 'O', chr(195).chr(147) => 'O',
    254     chr(195).chr(148) => 'O', chr(195).chr(149) => 'O',
    255     chr(195).chr(150) => 'O', chr(195).chr(153) => 'U',
    256     chr(195).chr(154) => 'U', chr(195).chr(155) => 'U',
    257     chr(195).chr(156) => 'U', chr(195).chr(157) => 'Y',
    258     chr(195).chr(159) => 's', chr(195).chr(160) => 'a',
    259     chr(195).chr(161) => 'a', chr(195).chr(162) => 'a',
    260     chr(195).chr(163) => 'a', chr(195).chr(164) => 'a',
    261     chr(195).chr(165) => 'a', chr(195).chr(167) => 'c',
    262     chr(195).chr(168) => 'e', chr(195).chr(169) => 'e',
    263     chr(195).chr(170) => 'e', chr(195).chr(171) => 'e',
    264     chr(195).chr(172) => 'i', chr(195).chr(173) => 'i',
    265     chr(195).chr(174) => 'i', chr(195).chr(175) => 'i',
    266     chr(195).chr(177) => 'n', chr(195).chr(178) => 'o',
    267     chr(195).chr(179) => 'o', chr(195).chr(180) => 'o',
    268     chr(195).chr(181) => 'o', chr(195).chr(182) => 'o',
    269     chr(195).chr(182) => 'o', chr(195).chr(185) => 'u',
    270     chr(195).chr(186) => 'u', chr(195).chr(187) => 'u',
    271     chr(195).chr(188) => 'u', chr(195).chr(189) => 'y',
    272     chr(195).chr(191) => 'y',
     245    "\xc3\x80"=>'A', "\xc3\x81"=>'A',
     246    "\xc3\x82"=>'A', "\xc3\x83"=>'A',
     247    "\xc3\x84"=>'A', "\xc3\x85"=>'A',
     248    "\xc3\x87"=>'C', "\xc3\x88"=>'E',
     249    "\xc3\x89"=>'E', "\xc3\x8a"=>'E',
     250    "\xc3\x8b"=>'E', "\xc3\x8c"=>'I',
     251    "\xc3\x8d"=>'I', "\xc3\x8e"=>'I',
     252    "\xc3\x8f"=>'I', "\xc3\x91"=>'N',
     253    "\xc3\x92"=>'O', "\xc3\x93"=>'O',
     254    "\xc3\x94"=>'O', "\xc3\x95"=>'O',
     255    "\xc3\x96"=>'O', "\xc3\x99"=>'U',
     256    "\xc3\x9a"=>'U', "\xc3\x9b"=>'U',
     257    "\xc3\x9c"=>'U', "\xc3\x9d"=>'Y',
     258    "\xc3\x9f"=>'s', "\xc3\xa0"=>'a',
     259    "\xc3\xa1"=>'a', "\xc3\xa2"=>'a',
     260    "\xc3\xa3"=>'a', "\xc3\xa4"=>'a',
     261    "\xc3\xa5"=>'a', "\xc3\xa7"=>'c',
     262    "\xc3\xa8"=>'e', "\xc3\xa9"=>'e',
     263    "\xc3\xaa"=>'e', "\xc3\xab"=>'e',
     264    "\xc3\xac"=>'i', "\xc3\xad"=>'i',
     265    "\xc3\xae"=>'i', "\xc3\xaf"=>'i',
     266    "\xc3\xb1"=>'n', "\xc3\xb2"=>'o',
     267    "\xc3\xb3"=>'o', "\xc3\xb4"=>'o',
     268    "\xc3\xb5"=>'o', "\xc3\xb6"=>'o',
     269    "\xc3\xb9"=>'u', "\xc3\xba"=>'u',
     270    "\xc3\xbb"=>'u', "\xc3\xbc"=>'u',
     271    "\xc3\xbd"=>'y', "\xc3\xbf"=>'y',
    273272    // Decompositions for Latin Extended-A
    274     chr(196).chr(128) => 'A', chr(196).chr(129) => 'a',
    275     chr(196).chr(130) => 'A', chr(196).chr(131) => 'a',
    276     chr(196).chr(132) => 'A', chr(196).chr(133) => 'a',
    277     chr(196).chr(134) => 'C', chr(196).chr(135) => 'c',
    278     chr(196).chr(136) => 'C', chr(196).chr(137) => 'c',
    279     chr(196).chr(138) => 'C', chr(196).chr(139) => 'c',
    280     chr(196).chr(140) => 'C', chr(196).chr(141) => 'c',
    281     chr(196).chr(142) => 'D', chr(196).chr(143) => 'd',
    282     chr(196).chr(144) => 'D', chr(196).chr(145) => 'd',
    283     chr(196).chr(146) => 'E', chr(196).chr(147) => 'e',
    284     chr(196).chr(148) => 'E', chr(196).chr(149) => 'e',
    285     chr(196).chr(150) => 'E', chr(196).chr(151) => 'e',
    286     chr(196).chr(152) => 'E', chr(196).chr(153) => 'e',
    287     chr(196).chr(154) => 'E', chr(196).chr(155) => 'e',
    288     chr(196).chr(156) => 'G', chr(196).chr(157) => 'g',
    289     chr(196).chr(158) => 'G', chr(196).chr(159) => 'g',
    290     chr(196).chr(160) => 'G', chr(196).chr(161) => 'g',
    291     chr(196).chr(162) => 'G', chr(196).chr(163) => 'g',
    292     chr(196).chr(164) => 'H', chr(196).chr(165) => 'h',
    293     chr(196).chr(166) => 'H', chr(196).chr(167) => 'h',
    294     chr(196).chr(168) => 'I', chr(196).chr(169) => 'i',
    295     chr(196).chr(170) => 'I', chr(196).chr(171) => 'i',
    296     chr(196).chr(172) => 'I', chr(196).chr(173) => 'i',
    297     chr(196).chr(174) => 'I', chr(196).chr(175) => 'i',
    298     chr(196).chr(176) => 'I', chr(196).chr(177) => 'i',
    299     chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij',
    300     chr(196).chr(180) => 'J', chr(196).chr(181) => 'j',
    301     chr(196).chr(182) => 'K', chr(196).chr(183) => 'k',
    302     chr(196).chr(184) => 'k', chr(196).chr(185) => 'L',
    303     chr(196).chr(186) => 'l', chr(196).chr(187) => 'L',
    304     chr(196).chr(188) => 'l', chr(196).chr(189) => 'L',
    305     chr(196).chr(190) => 'l', chr(196).chr(191) => 'L',
    306     chr(197).chr(128) => 'l', chr(197).chr(129) => 'L',
    307     chr(197).chr(130) => 'l', chr(197).chr(131) => 'N',
    308     chr(197).chr(132) => 'n', chr(197).chr(133) => 'N',
    309     chr(197).chr(134) => 'n', chr(197).chr(135) => 'N',
    310     chr(197).chr(136) => 'n', chr(197).chr(137) => 'N',
    311     chr(197).chr(138) => 'n', chr(197).chr(139) => 'N',
    312     chr(197).chr(140) => 'O', chr(197).chr(141) => 'o',
    313     chr(197).chr(142) => 'O', chr(197).chr(143) => 'o',
    314     chr(197).chr(144) => 'O', chr(197).chr(145) => 'o',
    315     chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe',
    316     chr(197).chr(148) => 'R',chr(197).chr(149) => 'r',
    317     chr(197).chr(150) => 'R',chr(197).chr(151) => 'r',
    318     chr(197).chr(152) => 'R',chr(197).chr(153) => 'r',
    319     chr(197).chr(154) => 'S',chr(197).chr(155) => 's',
    320     chr(197).chr(156) => 'S',chr(197).chr(157) => 's',
    321     chr(197).chr(158) => 'S',chr(197).chr(159) => 's',
    322     chr(197).chr(160) => 'S', chr(197).chr(161) => 's',
    323     chr(197).chr(162) => 'T', chr(197).chr(163) => 't',
    324     chr(197).chr(164) => 'T', chr(197).chr(165) => 't',
    325     chr(197).chr(166) => 'T', chr(197).chr(167) => 't',
    326     chr(197).chr(168) => 'U', chr(197).chr(169) => 'u',
    327     chr(197).chr(170) => 'U', chr(197).chr(171) => 'u',
    328     chr(197).chr(172) => 'U', chr(197).chr(173) => 'u',
    329     chr(197).chr(174) => 'U', chr(197).chr(175) => 'u',
    330     chr(197).chr(176) => 'U', chr(197).chr(177) => 'u',
    331     chr(197).chr(178) => 'U', chr(197).chr(179) => 'u',
    332     chr(197).chr(180) => 'W', chr(197).chr(181) => 'w',
    333     chr(197).chr(182) => 'Y', chr(197).chr(183) => 'y',
    334     chr(197).chr(184) => 'Y', chr(197).chr(185) => 'Z',
    335     chr(197).chr(186) => 'z', chr(197).chr(187) => 'Z',
    336     chr(197).chr(188) => 'z', chr(197).chr(189) => 'Z',
    337     chr(197).chr(190) => 'z', chr(197).chr(191) => 's',
     273    "\xc4\x80"=>'A', "\xc4\x81"=>'a',
     274    "\xc4\x82"=>'A', "\xc4\x83"=>'a',
     275    "\xc4\x84"=>'A', "\xc4\x85"=>'a',
     276    "\xc4\x86"=>'C', "\xc4\x87"=>'c',
     277    "\xc4\x88"=>'C', "\xc4\x89"=>'c',
     278    "\xc4\x8a"=>'C', "\xc4\x8b"=>'c',
     279    "\xc4\x8c"=>'C', "\xc4\x8d"=>'c',
     280    "\xc4\x8e"=>'D', "\xc4\x8f"=>'d',
     281    "\xc4\x90"=>'D', "\xc4\x91"=>'d',
     282    "\xc4\x92"=>'E', "\xc4\x93"=>'e',
     283    "\xc4\x94"=>'E', "\xc4\x95"=>'e',
     284    "\xc4\x96"=>'E', "\xc4\x97"=>'e',
     285    "\xc4\x98"=>'E', "\xc4\x99"=>'e',
     286    "\xc4\x9a"=>'E', "\xc4\x9b"=>'e',
     287    "\xc4\x9c"=>'G', "\xc4\x9d"=>'g',
     288    "\xc4\x9e"=>'G', "\xc4\x9f"=>'g',
     289    "\xc4\xa0"=>'G', "\xc4\xa1"=>'g',
     290    "\xc4\xa2"=>'G', "\xc4\xa3"=>'g',
     291    "\xc4\xa4"=>'H', "\xc4\xa5"=>'h',
     292    "\xc4\xa6"=>'H', "\xc4\xa7"=>'h',
     293    "\xc4\xa8"=>'I', "\xc4\xa9"=>'i',
     294    "\xc4\xaa"=>'I', "\xc4\xab"=>'i',
     295    "\xc4\xac"=>'I', "\xc4\xad"=>'i',
     296    "\xc4\xae"=>'I', "\xc4\xaf"=>'i',
     297    "\xc4\xb0"=>'I', "\xc4\xb1"=>'i',
     298    "\xc4\xb2"=>'IJ', "\xc4\xb3"=>'ij',
     299    "\xc4\xb4"=>'J', "\xc4\xb5"=>'j',
     300    "\xc4\xb6"=>'K', "\xc4\xb7"=>'k',
     301    "\xc4\xb8"=>'k', "\xc4\xb9"=>'L',
     302    "\xc4\xba"=>'l', "\xc4\xbb"=>'L',
     303    "\xc4\xbc"=>'l', "\xc4\xbd"=>'L',
     304    "\xc4\xbe"=>'l', "\xc4\xbf"=>'L',
     305    "\xc5\x80"=>'l', "\xc5\x81"=>'L',
     306    "\xc5\x82"=>'l', "\xc5\x83"=>'N',
     307    "\xc5\x84"=>'n', "\xc5\x85"=>'N',
     308    "\xc5\x86"=>'n', "\xc5\x87"=>'N',
     309    "\xc5\x88"=>'n', "\xc5\x89"=>'N',
     310    "\xc5\x8a"=>'n', "\xc5\x8b"=>'N',
     311    "\xc5\x8c"=>'O', "\xc5\x8d"=>'o',
     312    "\xc5\x8e"=>'O', "\xc5\x8f"=>'o',
     313    "\xc5\x90"=>'O', "\xc5\x91"=>'o',
     314    "\xc5\x92"=>'OE', "\xc5\x93"=>'oe',
     315    "\xc5\x94"=>'R', "\xc5\x95"=>'r',
     316    "\xc5\x96"=>'R', "\xc5\x97"=>'r',
     317    "\xc5\x98"=>'R', "\xc5\x99"=>'r',
     318    "\xc5\x9a"=>'S', "\xc5\x9b"=>'s',
     319    "\xc5\x9c"=>'S', "\xc5\x9d"=>'s',
     320    "\xc5\x9e"=>'S', "\xc5\x9f"=>'s',
     321    "\xc5\xa0"=>'S', "\xc5\xa1"=>'s',
     322    "\xc5\xa2"=>'T', "\xc5\xa3"=>'t',
     323    "\xc5\xa4"=>'T', "\xc5\xa5"=>'t',
     324    "\xc5\xa6"=>'T', "\xc5\xa7"=>'t',
     325    "\xc5\xa8"=>'U', "\xc5\xa9"=>'u',
     326    "\xc5\xaa"=>'U', "\xc5\xab"=>'u',
     327    "\xc5\xac"=>'U', "\xc5\xad"=>'u',
     328    "\xc5\xae"=>'U', "\xc5\xaf"=>'u',
     329    "\xc5\xb0"=>'U', "\xc5\xb1"=>'u',
     330    "\xc5\xb2"=>'U', "\xc5\xb3"=>'u',
     331    "\xc5\xb4"=>'W', "\xc5\xb5"=>'w',
     332    "\xc5\xb6"=>'Y', "\xc5\xb7"=>'y',
     333    "\xc5\xb8"=>'Y', "\xc5\xb9"=>'Z',
     334    "\xc5\xba"=>'z', "\xc5\xbb"=>'Z',
     335    "\xc5\xbc"=>'z', "\xc5\xbd"=>'Z',
     336    "\xc5\xbe"=>'z', "\xc5\xbf"=>'s',
    338337    // Euro Sign
    339     chr(226).chr(130).chr(172) => 'E',
     338    "\xe2\x82\xac"=>'E',
    340339    // GBP (Pound) Sign
    341     chr(194).chr(163) => '');
     340    "\xc2\xa3"=>'');
    342341
    343342    $string = strtr($string, $chars);
Note: See TracChangeset for help on using the changeset viewer.