[gspell/wip/apostrophe] apostrophes: support other unicode apostrophes



commit 0486930b54a220a1139b1b2c7c8e245cb7d20ed0
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Sat Mar 5 19:04:24 2016 +0100

    apostrophes: support other unicode apostrophes

 gspell/gspell-checker.c   |    2 ++
 gspell/gspell-text-iter.c |    4 +++-
 testsuite/test-checker.c  |   18 ++++++++++++++++++
 3 files changed, 23 insertions(+), 1 deletions(-)
---
diff --git a/gspell/gspell-checker.c b/gspell/gspell-checker.c
index 983ac23..8098811 100644
--- a/gspell/gspell-checker.c
+++ b/gspell/gspell-checker.c
@@ -373,6 +373,8 @@ gspell_checker_check_word (GspellChecker  *checker,
                return TRUE;
        }
 
+       /* TODO: Replace apostrophes. */
+
        enchant_result = enchant_dict_check (priv->dict, word, word_length);
 
        correctly_spelled = enchant_result == 0;
diff --git a/gspell/gspell-text-iter.c b/gspell/gspell-text-iter.c
index bd47bbe..3f28331 100644
--- a/gspell/gspell-text-iter.c
+++ b/gspell/gspell-text-iter.c
@@ -51,7 +51,9 @@ is_apostrophe (const GtkTextIter *iter)
 
        ch = gtk_text_iter_get_char (iter);
 
-       return ch == '\'';
+       return (ch == '\'' || /* Apostrophe U+0027 */
+               ch == 700 || /* Modifier Letter Apostrophe U+02BC */
+               ch == 8217); /* Right Single Quotation Mark U+2019 */
 }
 
 gboolean
diff --git a/testsuite/test-checker.c b/testsuite/test-checker.c
index 3a8b81a..b9b2525 100644
--- a/testsuite/test-checker.c
+++ b/testsuite/test-checker.c
@@ -66,6 +66,24 @@ test_apostrophes (void)
        g_assert_no_error (error);
        g_assert (correctly_spelled);
 
+       /* Modifier Letter Apostrophe U+02BC */
+
+       apostrophe_char = g_utf8_get_char ("\xCA\xBC");
+       g_assert_cmpint (apostrophe_char, ==, 700);
+
+       correctly_spelled = gspell_checker_check_word (checker, "doesn\xCA\xBCt", -1, &error);
+       g_assert_no_error (error);
+       g_assert (correctly_spelled);
+
+       /* Right Single Quotation Mark U+2019 */
+
+       apostrophe_char = g_utf8_get_char ("\xE2\x80\x99");
+       g_assert_cmpint (apostrophe_char, ==, 8217);
+
+       correctly_spelled = gspell_checker_check_word (checker, "doesn\xE2\x80\x99t", -1, &error);
+       g_assert_no_error (error);
+       g_assert (correctly_spelled);
+
        g_object_unref (checker);
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]