Den 2018-09-18 kl. 17:43, skrev Mark Rotteveel:
On 18-9-2018 17:33, Alex Peshkoff via Firebird-devel wrote:
Look like a bug. At least I do not see any place where engine transliterates TPB in the code. On the other hand not sure was this particular bug caused by this or with given connection parameters .net client should provide all string already in utf8.
Test case using native client is highly welcome.

It looks like the Firebird .net provider uses Encoding.Default for TPB string properties, which on most platforms - IIRC - is not UTF-8, see https://github.com/cincuranet/FirebirdSql.Data.FirebirdClient/blob/74580961c9ada64aea49dcaabacae0de4fac3540/Provider/src/FirebirdSql.Data.FirebirdClient/Common/TransactionParameterBuffer.cs#L38


The referenced line uses Encoding2.Default. Wondering what Encoding 2 is, I found it defined in Encoding2.cs (surprise!) as:

static class Encoding2
{
    public static Encoding Default
#if NETSTANDARD1_6
        => Encoding.UTF8;
#else
        => Encoding.Default;
#endif
}

In other words it's UTF8 on .NET standard 1.6, but on other platforms it's the same as Encoding.Default. According to MS docs:
https://docs.microsoft.com/en-us/dotnet/api/system.text.encoding.default?view=netframework-4.7.2
Encoding.Default varies and may be an ANSI code page. For .NET Core it's apparently always UTF8, which would seem to make the Encoding2 class above useless (but maybe 1.6 fails and Encoding2 fixes it?).

Anyway, it would be best to ditch Default and make an active correct choice, rather than relying on some platform dependent thing. Same with string.ToUpper, which should probably be replaced with string.ToUpperInvariant (or apply some actively chosen encoding) throughout.

Regards,
Kjell

<<attachment: kjell_rilbe.vcf>>

Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel

Reply via email to