예제 #1
0
 public function preSubmit(FormEvent $event)
 {
     $data = $event->getData();
     if (!is_string($data)) {
         return;
     }
     $event->setData(StringUtil::trim($data));
 }
예제 #2
0
 /**
  * @dataProvider spaceProvider
  */
 public function testTrimUtf8Separators($hex)
 {
     // Convert hexadecimal representation into binary
     // H: hex string, high nibble first (UCS-2BE)
     // *: repeat until end of string
     $binary = pack('H*', $hex);
     // Convert UCS-2BE to UTF-8
     $symbol = mb_convert_encoding($binary, 'UTF-8', 'UCS-2BE');
     $symbol = $symbol . "ab\ncd" . $symbol;
     $this->assertSame("ab\ncd", StringUtil::trim($symbol));
 }
예제 #3
0
 /**
  * @dataProvider spaceProvider
  */
 public function testTrimUtf8Separators($hex)
 {
     if (!function_exists('mb_convert_encoding')) {
         $this->markTestSkipped('The "mb_convert_encoding" function is not available');
     }
     // Convert hexadecimal representation into binary
     // H: hex string, high nibble first (UCS-2BE)
     // *: repeat until end of string
     $binary = pack('H*', $hex);
     // Convert UCS-2BE to UTF-8
     $symbol = mb_convert_encoding($binary, 'UTF-8', 'UCS-2BE');
     $symbol = $symbol . "ab\ncd" . $symbol;
     $this->assertSame("ab\ncd", StringUtil::trim($symbol));
 }