diff --git a/glossify.module b/glossify.module
index 2557b5a..6c93099 100644
--- a/glossify.module
+++ b/glossify.module
@@ -314,11 +314,11 @@ function _glossify_to_links($text, $terms, $type, $case_sensitivity, $first_only
         }
         $parent->insertBefore($link, $refnode);
 
-        $offset = $term_pos + strlen($term_txt);
+        $offset = $term_pos + drupal_strlen($term_txt);
 
         // last match, append remaining text
         if ($i == $hitcount - 1) {
-          $suffix = substr($text, $offset);
+          $suffix = drupal_substr($text, $offset);
           $parent->insertBefore($html_dom->createTextNode($suffix), $refnode);
         }
       }
