Breaks encoding in richtextbox

2020-04-04 07:07发布

I use richtextbox in my winform application. When I paste "ជំរាបសួរ Khmer" text all good:

enter image description here

But when I paste "'مرحب Arabic" text some problems appear: in the first insert having problems with the encoding:

enter image description here

I have not found any Enсoding properties in richtextbox. How do I solve the problem of encoding?

1条回答
乱世女痞
2楼-- · 2020-04-04 07:26

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;
        }
    }
}
查看更多
登录 后发表回答