Jump to content
  • 0

Problems about Unicode chatting and input.


haosura

Question

I want to ask if we can change all Input Box (chatbox, name box) into basic window Text Box or something already available. Because custom Chat Box conflict with Unicode Inputer.

Example when I want to input "á". The inputer must delete "a" then replace with "á" but current chat box may steal SendMessage or PostMessage of inputer, so it return "aá", for double Unicode like "toán" it's become "toanán". The only way to input Unicode I can use now is copy paste from Notepad. If u can input Unicode, pls suggest for me some inputer working well here pls.

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

I have solve the problem above, this is new source code for TextBox update. I make a recognize to find which text should be replaced and delete them first. This source is for Vietnamese. If u are using other languages, update the RemoveUnicode() with ur alphabet table.


    public static char RemoveUnicode(char chr)
    {
        string text2 = chr.ToString();

        string[] arr1 = new string[] { "á", "à", "ả", "ã", "ạ", "â", "ấ", "ầ", "ẩ", "ẫ", "ậ", "ă", "ắ", "ằ", "ẳ", "ẵ", "ặ",
    "đ",
    "é","è","ẻ","ẽ","ẹ","ê","ế","ề","ể","ễ","ệ",
    "í","ì","ỉ","ĩ","ị",
    "ó","ò","ỏ","õ","ọ","ô","ố","ồ","ổ","ỗ","ộ","ơ","ớ","ờ","ở","ỡ","ợ",
    "ú","ù","ủ","ũ","ụ","ư","ứ","ừ","ử","ữ","ự",
    "ý","ỳ","ỷ","ỹ","ỵ",};
        string[] arr2 = new string[] { "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a",
    "d",
    "e","e","e","e","e","e","e","e","e","e","e",
    "i","i","i","i","i",
    "o","o","o","o","o","o","o","o","o","o","o","o","o","o","o","o","o",
    "u","u","u","u","u","u","u","u","u","u","u",
    "y","y","y","y","y",};
        for (int i = 0; i < arr1.Length; i++)
        {
            text2 = text2.Replace(arr1[i], arr2[i]);
            text2 = text2.Replace(arr1[i].ToUpper(), arr2[i].ToUpper());
        }

        char res = char.Parse(text2);

        return res;
    }

    /// <summary>
    ///     Handler for character input event.
    /// </summary>
    /// <param name="chr">Character typed.</param>
    /// <returns>
    ///     True if handled.
    /// </returns>
    protected override bool OnChar(char chr)
    {
        base.OnChar(chr);

        if (chr == '\t')
        {
            return false;
        }

        if (chr >= (char)230)
        {
            char chrFind = RemoveUnicode(chr);

            //using (StreamWriter writetext = new StreamWriter("D:\\TEMP\\WriteLines.txt", true))
            //{
                //writetext.WriteLine(Text);
            //}
            int i;
            for (i = mCursorPos; i > 0; i--)
            {

                //using (StreamWriter writetext = new StreamWriter("D:\\TEMP\\WriteLines.txt", true))
                //{
                    //writetext.WriteLine(Text[i-1]);
                //}

                char checkChr = Text[i-1];
                if (checkChr == ' ')
                {
                    i = mCursorPos+1;
                    break;
                }

                char checkChrNormalize = RemoveUnicode(checkChr);
                if (chrFind == checkChrNormalize) break;
            }
            if (i>0&&i<= mCursorPos) {

            //using (StreamWriter writetext = new StreamWriter("D:\\TEMP\\WriteLines.txt", true))
            //{
            //writetext.WriteLine(Text[i-1]+' '+ i.ToString() + ' ' + Text.Length.ToString());
            //}

            DeleteText(i-1, Text.Length-i+1);

            }
            // for (int j = i-1; j < Text.Length; j++) OnKeyBackspace(true);

            //return false;
        }

        

        InsertText(chr.ToString());

        return true;
    }

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...