#49146 [Opn->Bgs]: strtr cuts char from the end

From: Date: Tue, 04 Aug 2009 01:38:13 +0000
Subject: #49146 [Opn->Bgs]: strtr cuts char from the end
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-140625@lists.php.net to get a copy of this message
ID: 49146 Updated by: scottmac@php.net Reported By: juho dot karvilainen at bmf dot wz dot cz -Status: Open +Status: Bogus Bug Type: Output Control Operating System: Win XP PHP Version: 5.2.10 New Comment: Closing PHP tags always eat the newline after it. Previous Comments: ------------------------------------------------------------------------ [2009-08-04 01:36:45] juho dot karvilainen at bmf dot wz dot cz Description: ------------ looks like the strtr() function (when used with array as 2nd argument) nibbles a character from the end when it has nothing to replace. (on UTF-8 page) Reproduce code: --------------- <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <?php function safe_js($str){ return strtr($str,array('"'=>'\"',"'">'\'','/'=>'\/')); } ?> line1...<?php echo safe_js(480)?> line2... Expected result: ---------------- line1...480 line2 Actual result: -------------- line1...48line2 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=49146&edit=1

« previous php.bugs (#140625) next »