Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"require": {
"php": ">=5.4.0",
"illuminate/support": "4.*",
"illuminate/container": "4.*"
"illuminate/container": "4.*",
"ext-mbstring": "*"
},
"require-dev": {
"phpunit/phpunit": "3.7.*",
Expand Down
31 changes: 27 additions & 4 deletions src/Filter/Filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,19 +181,42 @@ public function registerDefaultFilters()
});

$this->registerFilter('upper', function($value, array $args) {
return strtoupper($value);
return mb_strtoupper($value);
});

$this->registerFilter('lower', function($value, array $args) {
return strtolower($value);
return mb_strtolower($value);
});

$this->registerFilter('capfirst', function($value, array $args) {
return ucfirst($value);
return $this->mb_ucfirst($value);
});

$this->registerFilter('lowerfirst', function($value, array $args) {
return lcfirst($value);
return $this->mb_lcfirst($value);
});
}

/**
* @param $string
* @param string $encoding
* @return string
*/
protected function mb_ucfirst($string, $encoding = 'UTF-8')
{
$firstChar = mb_substr($string, 0, 1, $encoding);
$then = mb_substr($string, 1, null, $encoding);
return mb_strtoupper($firstChar, $encoding) . $then;
}

/**
* @param $string
* @return string
*/
protected function mb_lcfirst($string, $encoding = 'UTF-8')
{
$firstChar = mb_substr($string, 0, 1, $encoding);
$then = mb_substr($string, 1, null, $encoding);
return mb_strtolower($firstChar, $encoding) . $then;
}
}