ID: 20221 Updated by: [EMAIL PROTECTED] Reported By: panacode at skynet dot be Status: Bogus Bug Type: Strings related Operating System: Linux PHP Version: 4.2.3 New Comment:
Really? Then what is the value of $trans_tbl['ASCII'][13]? That looks zero-length to me. php_str_replace_in_subject() previously moved the search array forward and didn't move the replace array. This has since been fixed in CVS. J Previous Comments: ------------------------------------------------------------------------ [2003-06-24 11:39:17] heinz at hhombergs dot de But as you can see the search and the replace array in the function have no 0 length values and all three arrays are of the same size. ------------------------------------------------------------------------ [2003-06-20 10:09:05] [EMAIL PROTECTED] In php_str_replace_in_subject(), if a value in the search array is of 0 length, the search array internal pointer is moved ahead, but not the replace array. Shouldn't they both be moved ahead? This would produce the results panacode is expecting, but it would break BC, but I don't see any documentation that covers this behaviour. Unless I'm blind, of course, which I may be. J ------------------------------------------------------------------------ [2003-06-19 16:29:17] heinz at hhombergs dot de Sorry but there is a bug in the str_replace function. Reproduced under 4.2.2 and 4.3.2 function recode_charset($string,$cs_from,$cs_to) { $trans_tbl["ASCII"] = array("&", "¡", "¢", "£", "¤", "¥", "¦", "§", "¨", "©", "ª", "«", "¬", "", "®", "¯", "°", "±", "²", "³", "´", "µ", "¶", "·", "¸", "¹", "º", "»", "¼", "½", "¾", "¿", "À", "Á", "Â", "Ã", "Ä", "Å", "Æ", "Ç", "È", "É", "Ê", "Ë", "Ì", "Í", "Î", "Ï", "Ð", "Ñ", "Ò", "Ó", "Ô", "Õ", "Ö", "×", "Ø", "Ù", "Ú", "Û", "Ü", "Ý", "Þ", "ß", "à", "á", "â", "ã", "ä", "å", "æ", "ç", "è", "é", "ê", "ë", "ì", "í", "î", "ï", "ð", "ñ", "ò", "ó", "ô", "õ", "ö", "÷", "ø", "ù", "ú", "û", "ü", "ý", "þ", "ÿ"); $trans_tbl["UNICODE"] = array("&", "¡", "¢", "£", "¤", "¥", "¦", "§", "¨", "©", "ª", "«", "¬", "­", "®", "¯", "°", "±", "²", "³", "´", "µ", "¶", "·", "¸", "¹", "º", "»", "¼", "½", "¾", "¿", "À", "Á", "Â", "Ã", "Ä", "Å", "Æ", "Ç", "È", "É", "Ê", "Ë", "Ì", "Í", "Î", "Ï", "Ð", "Ñ", "Ò", "Ó", "Ô", "Õ", "Ö", "×", "Ø", "Ù", "Ú", "Û", "Ü", "Ý", "Þ", "ß", "à", "á", "â", "ã", "ä", "å", "æ", "ç", "è", "é", "ê", "ë", "ì", "í", "î", "ï", "ð", "ñ", "ò", "ó", "ô", "õ", "ö", "÷", "ø", "ù", "ú", "û", "ü", "ý", "þ", "ÿ"); $trans_tbl["HTML"] = array("&", "¡", "¢", "£", "¤", "¥", "¦", "§", "¨", "©", "ª", "«", "¬", "­", "®", "¯", "°", "±", "²", "³", "´", "µ", "¶", "·", "¸", "¹", "º", "»", "¼", "½", "¾", "¿", "À", "Á", "Â", "Ã", "Ä", "Å", "Æ", "Ç", "È", "É", "Ê", "Ë", "Ì", "Í", "Î", "Ï", "Ð", "Ñ", "Ò", "Ó", "Ô", "Õ", "Ö", "×", "Ø", "Ù", "Ú", "Û", "Ü", "Ý", "Þ", "ß", "à", "á", "â", "ã", "ä", "å", "æ", "ç", "è", "é", "ê", "ë", "ì", "í", "î", "ï", "ð", "ñ", "ò", "ó", "ô", "õ", "ö", "÷", "ø", "ù", "ú", "û", "ü", "ý", "þ", "ÿ"); return str_replace($trans_tbl[$cs_from], $trans_tbl[$cs_to], $string); } $string = recode_charset('ÄäÖöÜüß','ASCII','HTML'); will produce ÃãÛûÕõÞ but ÄäÜüÖöß is correct. ------------------------------------------------------------------------ [2002-11-02 17:46:51] [EMAIL PROTECTED] Sorry, but your problem does not imply a bug in PHP itself. For a list of more appropriate places to ask for help using PHP, please visit http://www.php.net/support.php as this bug system is not the appropriate forum for asking support questions. Thank you for your interest in PHP. ------------------------------------------------------------------------ [2002-11-02 17:43:08] panacode at skynet dot be Sorry for bothering (and for my writing errors). There actually is another function in PHP that has the behaviour that I expect: strtr(str, arr) $vReplace['@gill'] = '@doubleyou'; $vReplace['@doubleyou'] = '@bates'; $sSubject = "@gill @doubleyou is not my friend"; $sResult = strtr($sSubject, $vReplace); echo $sResult; // will output "@doubleyou @bates is not my friend" ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/20221 -- Edit this bug report at http://bugs.php.net/?id=20221&edit=1