Uthistran Selvaraj
Uthistran Selvaraj

Reputation: 1371

Euro Symbol not viewed in windows forms

I am trying to print the Euro Symbol in my Windows forms application with the following code. It works for all other characters & symbols, but Euro(€) is not displaying.

string input = ((char)128).ToString();
Font f = new System.Drawing.Font("Arial", 12f);
Graphics gr = this.CreateGraphics();
gr.DrawString(input, f, Brushes.Black, new PointF(0, 0));

128 - is the decimal of Euro sign Can anyone help on this?

Upvotes: 0

Views: 3281

Answers (2)

Uthistran Selvaraj
Uthistran Selvaraj

Reputation: 1371

By using the below code, I achieved printing Euro symbol without using unicode of it.

String input = Encoding.Default.GetString(new byte[] { 128 });
Font f = new System.Drawing.Font("Arial", 12f);
Graphics gr = this.CreateGraphics();
gr.DrawString(input, f, Brushes.Black, new PointF(0, 0));

This may help someone.

Upvotes: 1

Damien_The_Unbeliever
Damien_The_Unbeliever

Reputation: 239694

128 isn't the correct value to represent the Euro sign. Maybe try:

string input = ((char)0x20AC).ToString();

Because U+20AC is the Unicode code-point for a Euro sign.

Upvotes: 7

Related Questions