.NET Core System.Drawing.Common 中文乱码的坑

最近在写一个汉字取点阵的程序,最开始是在win环境下运行的,没发现什么异常,然后今天把程序放在centos 下后发现英文正常,中文完全变成两位的字了,最开始是字体的原因

在把宋体等安装到centos 后发现中文出来了 但完全变了另外的字,然后使用第三方的ZKWeb.System.Drawing 运行程序,发现正常,但切换回System.Drawing.Common 就会完全不认识 或者完全变了字

比如 :我是中文
画出来后变成了

.NET Core System.Drawing.Common 中文乱码的坑

 

 

 这完全不是这个了,阅读System.Drawing.Common的源码也并没有发现其中的坑在哪里 ,跟ZKWeb.System.Drawing 也对比了下,

找到关键性代码进行对比  System.Drawing.Common 中的源码

https://github.com/dotnet/corefx/blob/master/src/System.Drawing.Common/src/System/Drawing/GdiplusNative.cs

[DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Unicode)] internal static extern int GdipDrawString(HandleRef graphics, string textString, int length, HandleRef font, ref RectangleF layoutRect, HandleRef stringFormat, HandleRef brush);

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zydpdg.html