Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display (or write to file) Greek characters?

Tags:

string

c#

.net

How to display (or write to file) Greek characters using C#? I need to type the Greek character epsilon in Excel using C#. The string to be written also has English characters. For example:

enter image description here

like image 630
user2330678 Avatar asked Feb 19 '14 18:02

user2330678


People also ask

How do you insert Greek letters into a document?

Inserting Greek symbols by switching to the Symbol fontClick in the location in the document where you want to insert the letter or symbol. Press Ctrl + Shift + Q to switch to the Symbol font. Type the character to insert the required letter or symbol.

How do you put Greek letters in notepad?

To create any of these Greek letters using the Alt codes, simply press the "Alt" key while simultaneously typing the listed number. For example, to create the Greek letter Alpha (α), press the "Alt" key and type 224 using the keypad at the right side of your keyboard.

How do you display Greek characters in HTML?

To display a Greek character as it appears in the left column, use either the entity number or name. For example, to display the "Theta" character - "Θ" - use either Θ or Θ .


1 Answers

You can literally type the characters in your code. You can mix-and-match characters from any alphabet. So English and Greek characters in a single string is not a problem. If you don't know how to input them (e.g. if you don't have a Greek keyboard), then you can copy-and-paste them.

Console.Write("α");         // Greek lower-case alpha

Here is a list of lower-case and upper-case Greek characters for you to copy from:

α β γ δ ε ζ η θ ι κ λ μ ν ξ ο π ρ σ τ υ φ χ ψ ω
Α Β Γ Δ Ε Ζ Η Θ Ι Κ Λ Μ Ν Ξ Ο Π Ρ Σ Τ Υ Φ Χ Ψ Ω

If you're not using Visual Studio, you need to ensure that your text editor saves the code as Unicode (UTF-8).


Alternatively, you can use Unicode escape codes to write Greek characters.

Console.Write("\u03B1");    // Greek lower-case alpha

It is \u followed by the four-digit hexadecimal number of the character you want. You can find the hexadecimal values in this table. Simply ignore the &#x part.

like image 111
Daniel A.A. Pelsmaeker Avatar answered Sep 29 '22 12:09

Daniel A.A. Pelsmaeker