Giorgi / DuckDB.NET

Bindings and ADO.NET Provider for DuckDB
https://duckdb.net
MIT License
343 stars 62 forks source link

Simplify Utils.ToManagedString #47

Closed pkese closed 2 years ago

pkese commented 2 years ago

Marshal.PtrToStringAnsi does the same as what we were doing manually,
but without extra allocation for byteArray.

Giorgi commented 2 years ago

As the name says PtrToStringAnsi reads the string as Ansi but we need to treat them as Utf8

pkese commented 2 years ago

You're right, sorry about that.

PtrToStringAnsi does the correct thing on Linux (converts from Utf8), but on Windows it treats bytes according to system codepage.

There's a better fitting PtrToStringUTF8 but unfortunately it's not part of netstandard.

Giorgi commented 2 years ago

It's part of netstandard2.1 but not 2.0

pkese commented 2 years ago

I've added a switch to netstandard 2.1 and fixed the marshal call.

It's up to you to decide if this small change is worth considering the switch of the whole project to target netstandard 2.1.

Giorgi commented 2 years ago

I want to keep 2.0 for now.

pkese commented 2 years ago

Sure.