Skip to content

trim support for multibyte spaces / mb_trim() #9216

Closed
@8ctopus

Description

@8ctopus

Description

Hello!

the standard trim() function has a major flaw as it does not cleanup multibyte spaces.
I see two options to this problem:

  • implement mb_trim()
  • add support for multibyte spaces to the existing function

Code example in php 8.1.8

// does not work
echo var_dump(trim('小野 ')); // string(9) "小野 "

// temporary solution
echo var_dump(preg_replace("/^\s+|\s+$/u", "", "小野 ")); // string(6) "小野"

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions