Bug #6545 System.Text.Encoding.GetEncoding("latin1") fails on Mono
Submitted: 10 Nov 2004 11:16 Modified: 10 Nov 2004 14:15
Reporter: Stein Rustad Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / NET Severity:S3 (Non-critical)
Version:net-1.0.1-beta2 OS:Linux (Red Hat 8.0)
Assigned to: Reggie Burnett CPU Architecture:Any

[10 Nov 2004 11:16] Stein Rustad
Description:
Concerning the error with System.Text.Encoding.GetEncoding("latin1")

Even though the driver is supposed to use utf8 encoding internally and the cause for the error is the server sending back a resultset in latin1, when I have an all-utf8 server (system and all databases/tables/fields are utf8) the error still occurs.

Looking into the sourcecode, I see that in the constructor of Driver, System.Text.Encoding.GetEncoding("latin1") is hardcoded into it, and thus will always use latin1 encoding.
I know that Mono fixed the problem on their side, but it seems that the driver still does something weird. If the above call is a 'default' setting used until the first resultset is receieved, should it not be set to utf8?

How to repeat:
Create a new MySQLConnection under Mono 1.0.4

Suggested fix:
Remove or edit System.Text.Encoding.GetEncoding("latin1") in ctor of Driver
[10 Nov 2004 12:56] Stein Rustad
BTW DB is MySQL4.1.7
[10 Nov 2004 14:15] Reggie Burnett
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.mysql.com/documentation/ and the instructions on
how to report a bug at http://bugs.mysql.com/how-to-report.php

Additional info:

The reason that the driver starts out with latin1 is because we use latin1 for the initial username and password handshake.  It's only after making the initial connection that we learn what character set the server is set to and then we cha nge to that one.  Yes, I could perform the handshake without acquiring a latin1 encoding, but I don't see the need to work around a bug in Mono that's already been fixed.