问题
I use richtextbox in my winform application. When I paste "ជំរាបសួរ Khmer" text all good:
But when I paste "'مرحب Arabic" text some problems appear: in the first insert having problems with the encoding:
I have not found any Enсoding properties in richtextbox. How do I solve the problem of encoding?
回答1:
Use RichTextBox v5. The default in Visual Studio is v4. It fixes this problem among others.
public class RichText50W : RichTextBox
{
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
static extern IntPtr LoadLibrary(string lpFileName);
protected override CreateParams CreateParams
{
get
{
CreateParams prams = base.CreateParams;
if (LoadLibrary("msftedit.dll") != IntPtr.Zero)
{
prams.ClassName = "RICHEDIT50W";
}
return prams;
}
}
}
来源:https://stackoverflow.com/questions/19591369/breaks-encoding-in-richtextbox