From f4ea7262079eeda656c64fd59af4899d68cb6ad1 Mon Sep 17 00:00:00 2001 From: Francois Zaninotto Date: Tue, 1 Jan 2013 16:02:18 +0100 Subject: [PATCH] Fix UTF-8 bug Closes #79 --- src/Faker/Guesser/Name.php | 4 +++- src/Faker/ORM/Propel/EntityPopulator.php | 4 +++- src/Faker/Provider/Base.php | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Faker/Guesser/Name.php b/src/Faker/Guesser/Name.php index 47098f09..815cd31f 100644 --- a/src/Faker/Guesser/Name.php +++ b/src/Faker/Guesser/Name.php @@ -2,6 +2,8 @@ namespace Faker\Guesser; +use \Faker\Provider\Base; + class Name { protected $generator; @@ -13,7 +15,7 @@ class Name public function guessFormat($name) { - $name = static::toLower($name); + $name = Base::toLower($name); $generator = $this->generator; if (preg_match('/^is[_A-Z]/', $name)) { return function() use ($generator) { return $generator->boolean; }; diff --git a/src/Faker/ORM/Propel/EntityPopulator.php b/src/Faker/ORM/Propel/EntityPopulator.php index 768a0aad..0a70fbd8 100644 --- a/src/Faker/ORM/Propel/EntityPopulator.php +++ b/src/Faker/ORM/Propel/EntityPopulator.php @@ -2,6 +2,8 @@ namespace Faker\ORM\Propel; +use \Faker\Provider\Base; + /** * Service class for populating a table through a Propel ActiveRecord class. */ @@ -78,7 +80,7 @@ class EntityPopulator protected function isColumnBehavior($columnMap) { foreach ($columnMap->getTable()->getBehaviors() as $name => $params) { - $columnName = static::toLower($columnMap->getName()); + $columnName = Base::toLower($columnMap->getName()); switch ($name) { case 'nested_set': $columnNames = array($params['left_column'], $params['right_column'], $params['level_column']); diff --git a/src/Faker/Provider/Base.php b/src/Faker/Provider/Base.php index f5c2d808..5b9e265d 100644 --- a/src/Faker/Provider/Base.php +++ b/src/Faker/Provider/Base.php @@ -143,7 +143,7 @@ class Base */ public static function toLower($string = '') { - return extension_loaded('mbstring') ? mb_strtolower($string) : strtolower($string); + return extension_loaded('mbstring') ? mb_strtolower($string, 'UTF-8') : strtolower($string); } /** @@ -154,6 +154,6 @@ class Base */ public static function toUpper($string = '') { - return extension_loaded('mbstring') ? mb_strtoupper($string) : strtoupper($string); + return extension_loaded('mbstring') ? mb_strtoupper($string, 'UTF-8') : strtoupper($string); } }