Skip to content

Commit

Permalink
[+] added "UTF8::parse_str()"
Browse files Browse the repository at this point in the history
  • Loading branch information
Lars Moelleken committed Feb 22, 2015
1 parent fb2143c commit 00775d2
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/voku/helper/UTF8.php
Original file line number Diff line number Diff line change
Expand Up @@ -4577,6 +4577,28 @@ public static function ws()
return $white;
}

/**
* Parses the string into variables
*
* @link http://php.net/manual/en/function.parse-str.php
*
* @param string $str <p>
* The input string.
* </p>
* @param array $arr <p>
* If the second parameter arr is present,
* variables are stored in this variable as array elements instead.
* </p>
*
* @return void
*/
public static function parse_str($str, &$arr)
{
$str = self::filter($str);

parse_str($str, $arr);
}

/**
* return a array with "urlencoded"-win1252 -> UTF-8
*
Expand Down
11 changes: 11 additions & 0 deletions tests/UTF8Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,17 @@ public function testFixBrokenUtf8()
}
}

public function testParseStr()
{
$str = "Iñtërnâtiôn\xE9àlizætiøn=測試&arr[]=foo+測試&arr[]=ການທົດສອບ";
UTF8::parse_str($str, $array);

$this->assertEquals('測試', $array['Iñtërnâtiônéàlizætiøn']);
$this->assertEquals('foo 測試', $array['arr'][0]);
$this->assertEquals('ການທົດສອບ', $array['arr'][1]);

}

public function testIsUtf8()
{
$testArray = array(
Expand Down

0 comments on commit 00775d2

Please sign in to comment.