Breaks encoding in richtextbox

て烟熏妆下的殇ゞ 提交于 2019-12-19 17:33:04

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!