Permalink
Browse files

New string conversion function to help with multibyte-locales

  • Loading branch information...
1 parent 3ba2985 commit 7d6cac54f36832f25fb52635c027ae99202082a8 paca70 committed Apr 21, 2003
Showing with 13 additions and 0 deletions.
  1. +13 −0 lib/moodlelib.php
View
@@ -1253,6 +1253,19 @@ function moodle_needs_upgrading() {
/// MISCELLANEOUS ////////////////////////////////////////////////////////////////////
+function moodle_strtolower ($string, $encoding='') {
+/// Converts string to lowercase using most compatible function available
+ if (function_exists('mb_strtolower')) {
+ if($encoding===''){
+ return mb_strtolower($string); //use multibyte support with default encoding
+ } else {
+ return mb_strtolower($string,encoding); //use given encoding
+ }
+ } else {
+ return strtolower($string); // use common function what rely on current locale setting
+ }
+}
+
function count_words($string) {
/// Words are defined as things between whitespace
$string = strip_tags($string);

0 comments on commit 7d6cac5

Please sign in to comment.