diff --git a/src/Util.php b/src/Util.php index 220f98da..6bf1c802 100644 --- a/src/Util.php +++ b/src/Util.php @@ -317,7 +317,7 @@ public static function normalizeChars($string) 'ß' => 'sz', 'þ' => 'thorn', 'º' => '', 'ª' => '', '°' => '', ); - return strtr($string, $normalizeChars); + return preg_replace('/[^0-9a-zA-Z !*\-$\(\)\[\]\{\},.;:\/\\#%&@+=]/', '', strtr($string, $normalizeChars)); } /** @@ -474,6 +474,7 @@ public static function numberFormatGeral($n, $loop, $insert = 0) public static function formatCnab($tipo, $valor, $tamanho, $dec = 0, $sFill = '') { $tipo = self::upper($tipo); + $valor = self::upper(self::normalizeChars($valor)); if (in_array($tipo, array('9', 9, 'N', '9L', 'NL'))) { if ($tipo == '9L' || $tipo == 'NL') { $valor = self::onlyNumbers($valor); @@ -486,7 +487,6 @@ public static function formatCnab($tipo, $valor, $tamanho, $dec = 0, $sFill = '' } elseif (in_array($tipo, array('A', 'X'))) { $left = '-'; $type = 's'; - $valor = self::upper(self::normalizeChars($valor)); } else { throw new \Exception('Tipo inválido'); }