如何显示(或写入文件)希腊字符? [英] How to display (or write to file) Greek characters?
问题描述
如何使用C#显示(或写入文件)希腊字符?我需要使用C#在Excel中键入希腊字符 epsilon .要写的字符串也有英文字符.例如:
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:
推荐答案
您可以直接在代码中键入字符.您可以混合和匹配来自任何字母的字符.因此,单个字符串中的英语和希腊字符不是问题.如果您不知道如何输入(例如,如果您没有希腊语键盘),则可以复制并粘贴它们.
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:
α β γ δ ε ζ η θ ι κ λ μ ν ξ ο π ρ σ τ υ φ χ ψ ω
Α Β Γ Δ Ε Ζ Η Θ Ι Κ Λ Μ Ν Ξ Ο Π Ρ Σ Τ Υ Φ Χ Ψ Ω
如果您不使用Visual Studio,则需要确保您的文本编辑器将代码另存为Unicode(UTF-8).
If you're not using Visual Studio, you need to ensure that your text editor saves the code as Unicode (UTF-8).
或者,您可以使用 Unicode转义码编写希腊字符.
Alternatively, you can use Unicode escape codes to write Greek characters.
Console.Write("\u03B1"); // Greek lower-case alpha
它是 \ u
,后跟所需字符的四位数十六进制数字.您可以在此表中找到十六进制值.只需忽略& #x
部分.
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.
这篇关于如何显示(或写入文件)希腊字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!