Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual studio application, XP adds an extra square character at the start of some labels

My application, created with visual studio 2010 express, looks fine in all Windows version, other than XP.

XP adds an extra square character at the start of some of the labels.

Comparison of screenshots of application in XP and other than XP

The properties of all labels, whether they displays the extra character or not, are the same:

  • Microsoft Sans Serif, 8.25pt
  • Autosize: true
  • Forecolor: ControlText

The only difference is the location, width, and, of course, the text.

It doesn't seem to be related on whether a special characters such as Omega is used. It is not related to the width.

Form the (application).Designer.cs:

This label is OK:

        // label22
        // 
        this.label22.AutoSize = true;
        this.label22.Location = new System.Drawing.Point(58, 23);
        this.label22.Name = "label22";
        this.label22.Size = new System.Drawing.Size(20, 13);
        this.label22.TabIndex = 32;
        this.label22.Text = "Ah";

This label adds a funny character:

        // lblPackCurrUnits
        // 
        this.lblPackCurrUnits.AutoSize = true;
        this.lblPackCurrUnits.Location = new System.Drawing.Point(44, 300);
        this.lblPackCurrUnits.Name = "lblPackCurrUnits";
        this.lblPackCurrUnits.Size = new System.Drawing.Size(14, 13);
        this.lblPackCurrUnits.TabIndex = 17;
        this.lblPackCurrUnits.Text = "◊A";

Any idea of what causes that?

Well, well, well! Lookie there! There's a funny character in that last line! Pasting the code into stackoverflow revealed the problem!

There ARE funny characters in there. It's just that they are invisible in the Visual Studio text editor, and in any other editor I tried. They only appear when I paste them here! Who created them?

OK, I have my solution: I will hand-edit the Designer.cs file.

But I am keeping this question here, so that others may benefit from it.

like image 393
Davide Andrea Avatar asked Jun 25 '13 16:06

Davide Andrea


1 Answers

I suspect that you're getting a byte order mark or some other Unicode marker (e.g., a zero-width joiner, non-joiner, or zero-width space) embedded in the designer. These are perfectly valid characters, but XP fonts would not have representations for that character, and hence you get the square filler.

like image 85
Eric Brown Avatar answered Nov 09 '22 00:11

Eric Brown