Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

Commit

Permalink
Fix broken decimal separator replacement when it is more than one byt…
Browse files Browse the repository at this point in the history
…e length (don't assume it's length always 1)
  • Loading branch information
phamcuongmp committed Oct 1, 2021
1 parent 3d1f5ac commit bdd0ae5
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,9 @@ public function getDirectoryCurrency($result, $decimal, $original, $config)
return str_replace($original['groupSymbol'], $config['group_separator'], $processedCurrency);
}

$decimalPart = substr($result, -($decimal + 1), $decimal + 1);
$currencyPart = substr($result, 0, strlen($result) - ($decimal + 1));
$decimalSeparatorLength = strlen($original['decimalSymbol']);
$decimalPart = substr($result, -($decimal + $decimalSeparatorLength), $decimal + $decimalSeparatorLength);
$currencyPart = substr($result, 0, strlen($result) - ($decimal + $decimalSeparatorLength));
$currencyPartResult = str_replace($original['groupSymbol'], $config['group_separator'], $currencyPart);
$decimalPartResult = str_replace($original['decimalSymbol'], $config['decimal_separator'], $decimalPart);
$result = $currencyPartResult . $decimalPartResult;
Expand Down

0 comments on commit bdd0ae5

Please sign in to comment.