Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Removed UTF-8 retardness.

  • Loading branch information...
commit 17235e6a53ee19d131e9e44434616a48d239adcd 1 parent e4e9e87
Kasper Johansen authored
Showing with 2 additions and 5 deletions.
  1. +2 −5 strings.php
View
7 strings.php
@@ -2,10 +2,7 @@
class knj_strings{
static function substr($string, $len1, $len2){
- $string = utf8_decode($string);
- $string = substr($string, $len1, $len2);
- $string = utf8_encode($string);
- return $string;
+ return mb_substr($string, $len1, $len2, mb_detect_encoding($string));
}
static function utf8wrapper($func, $arg1){
@@ -184,7 +181,7 @@ static function shorten($text, $maxlength = nil){
return $text;
}
- return utf8_encode(trim(substr(utf8_decode($text), 0, $maxlength))) . "...";
+ return trim(mb_substr($text, 0, $maxlength, mb_detect_encoding($text))) . "...";
}
static function is_email($str){

1 comment on commit 17235e6

@AJenbo

You should probably look in my branch for a similar fix to knj_strings::utf8force().

Please sign in to comment.
Something went wrong with that request. Please try again.