Пример #1
0
        internal void PasteClipboard()
        {
            // Paste clipboard.
            var text = Clipboard.GetText();

            if (!string.IsNullOrEmpty(text))
            {
                //
                // Convert to Unix line endings, otherwise pasting a multi-
                // line command will be interpreted as a sequence of
                // commands.
                //
                text = text.Replace("\r\n", "\n");

                if (this.EnableTypographicQuoteConversionOnPaste)
                {
                    // Copied code snippets might contain typographic
                    // quotes (thanks to Word and Docs) - convert them
                    // to plain ASCII single/double quotes.
                    text = TypographicQuotes.ToAsciiQuotes(text);
                }

                this.controller.Paste(Encoding.UTF8.GetBytes(text));
            }
        }
Пример #2
0
        public void WhenStringContainsTypograhicDoubleQuotes_ThenToAsciiQuotesReturnsSanitizedString()
        {
            var s = "These are \u201CEnglish\u201d, \u201eGerman\u201c, and \u00bbFrench\u00ab double quotes";

            Assert.AreEqual(
                "These are \"English\", \"German\", and \"French\" double quotes",
                TypographicQuotes.ToAsciiQuotes(s));
        }
Пример #3
0
        public void WhenStringContainsTypograhicSingleQuotes_ThenToAsciiQuotesReturnsSanitizedString()
        {
            var s = "These are \u2018English\u2019, \u201aGerman\u2018, and \u203aFrench\u2039 single quotes";

            Assert.AreEqual(
                "These are \'English\', \'German\', and \'French\' single quotes",
                TypographicQuotes.ToAsciiQuotes(s));
        }
Пример #4
0
        public void WhenStringContainsNoTypograhicQuotes_ThenToAsciiQuotesReturnsSameString()
        {
            var s = "This isn't \"typographic\" but `plain´ ASCII";

            Assert.AreEqual(s, TypographicQuotes.ToAsciiQuotes(s));
        }