I have some codes with PHP;
I serched an convert PHP code . And My B4a code is:
My questions is myB4A code return same PHP return data??
PHP:
function _UTF8toUTF16($s)
{
// UTF-8 to UTF-16BE with BOM
$res = "\xFE\xFF";
$nb = strlen($s);
$i = 0;
while($i<$nb)
{
$c1 = ord($s[$i++]);
if($c1>=224)
{
// 3-byte character
$c2 = ord($s[$i++]);
$c3 = ord($s[$i++]);
$res .= chr((($c1 & 0x0F)<<4) + (($c2 & 0x3C)>>2));
$res .= chr((($c2 & 0x03)<<6) + ($c3 & 0x3F));
}
elseif($c1>=192)
{
// 2-byte character
$c2 = ord($s[$i++]);
$res .= chr(($c1 & 0x1C)>>2);
$res .= chr((($c1 & 0x03)<<6) + ($c2 & 0x3F));
}
else
{
// Single-byte character
$res .= "\0".chr($c1);
}
}
return $res;
}
I serched an convert PHP code . And My B4a code is:
B4X:
Sub UTF8toUTF16(data As String) As String
Dim bb() As Byte
bb=data.GetBytes("UTF16")
Return BytesToString(bb,0,bb.Length,"UTF16")
End Sub
My questions is myB4A code return same PHP return data??