Skip to content

Commit

Permalink
normalize string
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardokum committed Aug 31, 2018
1 parent 16de68f commit 1fbd73c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

/**
Expand Down Expand Up @@ -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);
Expand All @@ -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');
}
Expand Down

0 comments on commit 1fbd73c

Please sign in to comment.