PocketMine-MP icon indicating copy to clipboard operation
PocketMine-MP copied to clipboard

Replaced `strtolower` and `strtoupper` functions to `mb_strtolower` and `mb_strtoupper`

Open JavierLeon9966 opened this issue 3 years ago • 2 comments

Introduction

Currently strtolower and strtoupper changes result according to system locale. This could lead to some bugs listed by the issue below. This pull request replaces every strtolower and strtoupper to mb_strtolower and mb_strtoupper.

Relevant issues

  • Fixes #3585

Changes

API changes

None

Behavioural changes

Any code that uses lowercase or uppercase letters now don’t have locale-dependent behavior.

Backwards compatibility

None

Follow-up

None

Tests

  • [ ]

JavierLeon9966 avatar Jan 07 '22 15:01 JavierLeon9966

This has lots of side effects and potential ramifications that haven't been explored. There is a reason I haven't already done this myself.

This will cause behavioural changes in many areas, particularly where non-ASCII encodings are involved, since they'll start getting transformed in ways that wasn't anticipated when the code was written. A more conservative approach would be to use US-ASCII for the encoding parameters.

dktapps avatar Jan 17 '22 20:01 dktapps

Done

JavierLeon9966 avatar Jan 18 '22 23:01 JavierLeon9966

This is now obsoleted by PHP 8.2, which made the standard library string manipulation functions locale-unaware (manipulating ASCII only).

dktapps avatar Feb 19 '24 16:02 dktapps