|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2010-10-22 15:47 UTC] kalle@php.net
-Package: Strings related
+Package: Documentation problem
[2010-10-23 02:12 UTC] cataphract@php.net
-Status: Open
+Status: Closed
-Assigned To:
+Assigned To: cataphract
[2010-10-23 02:12 UTC] cataphract@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 08 20:00:02 2026 UTC |
Description: ------------ strtr() only translates _bytes_, not characters. When translating a multi-byte character to a single byte character, only the first byte is converted, resulting in a broken string. The examples given in the doc work with an ISO-8859-1 encoding of the source file, but not with UTF-8. IMHO, two solutions; 1) Fix the function. But then the function would need to guess the file encoding. Hmmm....PHP6? 2) Fix the doc. The doc title, "strtr — Translate certain characters", is misleading. Either replace "characters" by "bytes", or add somewhere on the page that it only works on single-byte encodings. A big warning would be useful. Test script: --------------- // in an UTF-8 file echo strtr("’", "’", "'"); echo strtr("äåö", "äåö", "aao"); // example from php.net Expected result: ---------------- 'aao Actual result: -------------- '��oao�o�