public override void SendText()

in sources/Google.Solutions.Terminal/Controls/RdpClient.cs [1095:1144]


        public override void SendText(string text)
        {
            Debug.Assert(this.State == ConnectionState.LoggedOn);
            if (this.State != ConnectionState.LoggedOn)
            {
                return;
            }

            if (string.IsNullOrEmpty(text))
            {
                return;
            }

            var keyboardLayout = KeyboardLayout.Current;

            for (var i = 0; i < text.Length && i < MaxSendStringLength; i++)
            {
                var ch = text[i];
                if (ch == '\r' && i < text.Length - 2 && text[i + 1] == '\n')
                {
                    //
                    // Ignore a CR if it's part of a CRLF.
                    //
                    continue;
                }

                if (keyboardLayout.TryMapVirtualKey(ch, out var vk))
                {
                    //
                    // This is a "mormal" character with a corresponding
                    // virtual key on the current keyboard layout.
                    //
                    SendVirtualKey(vk);
                }
                else
                {
                    //
                    // This is a ligature or any kind of character that
                    // has no corresponding virtual on the current keyboard layout.
                    //
                    // Converting the character to a Alt+0nnn sequence doesn't
                    // work reliably, so we just send a '?'.
                    //
                    if (keyboardLayout.TryMapVirtualKey('?', out var questionMark))
                    {
                        SendVirtualKey(questionMark);
                    }
                }
            }
        }