Closed kripper closed 1 year ago
base64_encode(chr(220))
also gives a wrong result.
BTW, the test case can be easily placed inside PHPScripts/index.php
following the instructions here:
https://www.peachpie.io/2021/08/run-debug-php-browser.html
Then execute dotnet run
inside BlazorApp\Client
.
Hi @jakubmisek, do you know if there is some configuration or workaround to support working with binary strings on PeachPie WebAssemblies?
@kripper there is nothing special for webasm, just a thin wrapper at https://github.com/peachpiecompiler/peachpie-blazor . Strings are handled the same
Right. I tested on peachpie (latest version) and both asserts fail too for a console app.
I tried adding the (binary)
cast, using mb_chr(220, 'ASCII')
, but everything fails.
Is there any way to create a binary string containig chr(220)?
chr(220) // == new byte[]{ 220 }
It seems like chr() only returns binary strings when bytevalue < 240.
public static PhpString chr(int bytevalue)
{
if (bytevalue < 0xf0)
{
return ((char)bytevalue).ToString();
}
else
{
return new PhpString(new byte[] { (byte)bytevalue });
}
}
Can we add an option to make chr()
compatbile with Zend's PHP?
I believe most of the time we see chr()
in the code is because the programmer wants to generate binary code.
seems like a typo, should be string
only for 32 <= bytevalue < 128
Agree.
Tested and working fine after https://github.com/peachpiecompiler/peachpie/pull/982
This asserts fail when working with WebAssemblies: