peachpie
peachpie copied to clipboard
function strlen should be the byte count of the string
For example: strlen("张三") //should be 6,php code Encoding.Default.GetByteCount("张三")
if we edit the code of peachpie,there are many functions should be edited,such as "strpos","strrpos","fread"....
You are right, in general, there are some incompatibilities.
We have tried to make PHP Unicode safe and to take advantage of the .NET native String
(UTF-16) type.
There are some known exceptions described at https://docs.peachpie.io/php/unicode/
Wherever you need to treat the value as 8-bit string, you can cast it using (binary)
operator, e.g.:
strlen( (binary)"张三" );
Currently, this is a known behavior, and basically, we are still evaluating what would be the right approach.
- https://github.com/peachpiecompiler/peachpie/issues/930
- https://github.com/peachpiecompiler/peachpie/issues/929
- https://github.com/peachpiecompiler/peachpie/issues/910
- https://github.com/peachpiecompiler/peachpie/issues/778
- https://github.com/peachpiecompiler/peachpie/issues/565