From a8f5a8a2e4bd8fac633756a7e8308411a4231889 Mon Sep 17 00:00:00 2001 From: skodak Date: Sun, 8 Oct 2006 10:07:03 +0000 Subject: [PATCH] Insert a Chinese charachter string to label resource result error MDL-6757 --- mod/label/lib.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/mod/label/lib.php b/mod/label/lib.php index 1631570c09..47c60bc932 100644 --- a/mod/label/lib.php +++ b/mod/label/lib.php @@ -10,10 +10,11 @@ function label_add_instance($label) { /// (defined by the form in mod.html) this function /// will create a new instance and return the id number /// of the new instance. + $textlib = textlib_get_instance(); $label->name = addslashes(strip_tags(format_string(stripslashes($label->content),true))); - if (strlen($label->name) > LABEL_MAX_NAME_LENGTH) { - $label->name = substr($label->name, 0, LABEL_MAX_NAME_LENGTH)."..."; + if ($textlib->strlen($label->name, current_charset()) > LABEL_MAX_NAME_LENGTH) { + $label->name = $textlib->substr($label->name, 0, LABEL_MAX_NAME_LENGTH, current_charset())."..."; } $label->timemodified = time(); @@ -25,10 +26,11 @@ function label_update_instance($label) { /// Given an object containing all the necessary data, /// (defined by the form in mod.html) this function /// will update an existing instance with new data. + $textlib = textlib_get_instance(); $label->name = addslashes(strip_tags(format_string(stripslashes($label->content),true))); - if (strlen($label->name) > LABEL_MAX_NAME_LENGTH) { - $label->name = substr($label->name, 0, LABEL_MAX_NAME_LENGTH)."..."; + if ($textlib->strlen($label->name, current_charset()) > LABEL_MAX_NAME_LENGTH) { + $label->name = $textlib->substr($label->name, 0, LABEL_MAX_NAME_LENGTH, current_charset())."..."; } $label->timemodified = time(); $label->id = $label->instance; -- 2.39.5