php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #65132 trim does not include non breaking whitespace
Submitted: 2013-06-26 08:19 UTC Modified: 2013-06-26 15:49 UTC
From: daniel at 203core dot se Assigned:
Status: Wont fix Package: Strings related
PHP Version: 5.4.16 OS: FreeBSD 9.1
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
11 + 34 = ?
Subscribe to this entry?

 
 [2013-06-26 08:19 UTC] daniel at 203core dot se
Description:
------------
If a line contains a non-breaking white space (\xA0) trim doesnt strip it, it should as its a "space" character

This can easily be bypassed by sending the \xA0 character in the option parameter but it took a while to figure out there was a non-breaking space character in the string

Test script:
---------------
<?php

$string = " \xA0";
echo strlen(trim($string));

Expected result:
----------------
the script should output a length of 0

Actual result:
--------------
The script outputs a length of 1 as trim doesnt strip the non breaking space

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-06-26 15:49 UTC] aharvey@php.net
-Status: Open +Status: Wont fix -Package: Scripting Engine problem +Package: Strings related
 [2013-06-26 15:49 UTC] aharvey@php.net
There are multibyte encodings which are ASCII compatible where a0 is a valid byte 
in non-space characters, Shift JIS being the most obvious one. There would also 
be the issue that a0 is only part of the non-breaking space character in UTF-8 — 
to trim UTF-8 NBSPs, you'd have to also include c2, which would cause even more 
problems.

As a result, we can't really change this. Closing won't fix.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 11:01:30 2024 UTC