-
-
Notifications
You must be signed in to change notification settings - Fork 84
Open
nanoframework/nf-interpreter
#3191Description
Library/API/IoT binding
System.Text
Visual Studio version
VS2022 17.13.2
.NET nanoFramework extension version
2022.14.1.1
Target name(s)
ESP32 REV3
Firmware version
1.12.4.289
Device capabilities
No response
Description
The Encoding.UTF8.GetString throws an exception in nF where as in the .Net 8 it does not.
How to reproduce
public class Program
{
public static void Main()
{
Debug.WriteLine("Hello from nanoFramework!");
byte[] bytes = new byte[6] { 0x42, 0x41, 0x44, 0xff, 0xfe, 0xfd };
var st = Encoding.UTF8.GetString(bytes,0,6);
Console.WriteLine(st);
Thread.Sleep(Timeout.Infinite);
}
}
Expected behaviour
Do not throw an exception and invalid character should be replaced with U+FFFD (0xEF, 0xBF, 0xBD).
Screenshots
No response
Sample project or code
No response
Aditional information
++++ Exception System.Exception - CLR_E_WRONG_TYPE (1) ++++
++++ Message:
++++ System.Text.UTF8Encoding::GetChars [IP: 0000] ++++
++++ System.Text.Encoding::GetString [IP: 0007] ++++
++++ nanoFramework_string_utf8.Program::Main [IP: 0021] ++++
Exception thrown: 'System.Exception' in nanoFramework.System.Text.dll