Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Outputting a Unicode character in C#

I'm new to programming and self taught. I'm trying to output the astrological symbol for Taurus, which is supposed to be U+2649 in Unicode. Here is the code I'm using...

string myString = "\u2649";
byte[] unicode = System.Text.Encoding.Unicode.GetBytes(myString);
Console.WriteLine(unicode.Length);

The result I'm getting is the number 2 instead of the symbol or font. I'm sure I'm doing something wrong.

like image 988
Ed Olson Avatar asked Jul 01 '10 22:07

Ed Olson


2 Answers

Why are you converting it to unicode, this will not do anything.. lose the conversion and do the following:

string a ="\u2649"  ; 

Console.write(a) ; 
like image 63
mousa Avatar answered Sep 20 '22 15:09

mousa


You need to have a font which displays that glyph. If you do, then:

Console.WriteLine(myString); 

is all you need.

EDIT: Note, the only font I could find which has this glyph is "MS Reference Sans Serif".

like image 33
codekaizen Avatar answered Sep 20 '22 15:09

codekaizen