private void button1_Click(object sender, EventArgs e)
{
string str = "අම්මා";
byte[] utf8Bytes = Encoding.UTF8.GetBytes(str);
String productLine = Encoding.UTF8.GetString(utf8Bytes);
PrintDocument p = new PrintDocument();
p.PrintPage += delegate(object sender1, PrintPageEventArgs e1)
{
e1.Graphics.DrawString(productLine, new Font("Iskoola Pota", 18), new SolidBrush(Color.Black), new RectangleF(0, 0, p.DefaultPageSettings.PrintableArea.Width, p.DefaultPageSettings.PrintableArea.Height));
};
try
{
p.Print();
}
catch (Exception ex)
{
throw new Exception("Exception Occured While Printing", ex);
}
}
这段代码可以运行,但我的文本是"අම්මා",但它显示为අ්මමා",请帮助我以正确的方式显示。 "Iskoola Pota" 是 Unicode 字体。
str
吗?如果这样做会有什么结果? - Fildor