Bug #5962 Special characters don't get displayed
Submitted: 7 Oct 2004 20:26 Modified: 15 Nov 2004 17:43
Reporter: David Cumps Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / NET Severity:S3 (Non-critical)
Version:1.0 OS:
Assigned to: Reggie Burnett CPU Architecture:Any

[7 Oct 2004 20:26] David Cumps
Description:
Word characters get displayed as empty squares.

My guess it's something about encoding. But I tried it one 3 different systems with 3 different mysql installs, all getting the same result, so I got unsure about the cause.

How to repeat:
Use any of the following, fetch them and display them:

–
‘
’
“
”
…
[13 Oct 2004 16:44] Reggie Burnett
How are you trying to display them?  I think this may have more to do with how you are presenting them than how the connector is retrieving them.
[13 Oct 2004 16:52] David Cumps
Displaying:
DataRow TextItem = TextDb.GetTextItem(textId, (int)this.TextSort);
Response.Write(TextItem["txtItem"].ToString());

Fetching:
		public DataRow GetTextItem(int textId, int txtType) {
			string TextSQL = "SELECT * FROM snText WHERE txtId=?textid AND txtType=?type;";
			MySqlCommand TextCmd = new MySqlCommand(TextSQL, this.Database); 
			TextCmd.Parameters.Add(new MySqlParameter("?textid", textId)); 
			TextCmd.Parameters.Add(new MySqlParameter("?type", txtType.ToString())); 
			MySqlDataAdapter AdapterNews = new MySqlDataAdapter(TextCmd);
			DataSet Text = new DataSet();
			AdapterNews.Fill(Text);
			if (Text.Tables[0].Rows.Count != 0) {
				return Text.Tables[0].Rows[0];
			} else {
				return null;
			}
		} /* GetTextItem */

----
Al other settings are default ASP.NET and MySQL settings (Web.Config, charsets, ...)
[2 Nov 2004 20:57] Reggie Burnett
Can you give me the ascii or unicode codes for these characters?
[2 Nov 2004 21:14] David Cumps
Using C#:
Console.WriteLine("– : " + (int)'…');
Console.WriteLine("‘ : " + (int)'‘');
Console.WriteLine("’ : " + (int)'’');
Console.WriteLine("“ : " + (int)'“');
Console.WriteLine("” : " + (int)'”');
Console.WriteLine("… : " + (int)'…');

resulting:
- : 8230
` : 8216
' : 8217
" : 8220
" : 8221
. : 8230

Using VB6:
Text1.Text = "– " & Asc("–") & vbCrLf
Text1.Text = Text1.Text & "‘ " & Asc("‘") & vbCrLf
Text1.Text = Text1.Text & "’ " & Asc("’") & vbCrLf
Text1.Text = Text1.Text & "“ " & Asc("“") & vbCrLf
Text1.Text = Text1.Text & "” " & Asc("”") & vbCrLf
Text1.Text = Text1.Text & "… " & Asc("…")

Resulting:
– 150
‘ 145
’ 146
“ 147
” 148
… 133

Never been so hard to get ascii values ;)
[3 Nov 2004 14:40] Reggie Burnett
What version of MySQL are you using?
[3 Nov 2004 22:23] David Cumps
Running: MySQL 3.23.49-nt
[15 Nov 2004 17:43] Reggie Burnett
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html

Additional info:

I am marking this fixed and closed because I have added a charset option to the connection string.  These characters work fine on 4.1 so I think it is a character set issue.

These codes are > 0x79 so you should make sure you are using latin1 everywhere.  If utf-8 is involved, then codes above 0x79 become two byte code and this can cause problems.