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

后端 未结 1 730
夕颜
夕颜 2021-01-02 16:54

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

相关标签:
1条回答
  • 2021-01-02 17:00

    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.

    0 讨论(0)
提交回复
热议问题