diff --git a/CHANGELOG.md b/CHANGELOG.md index e1d2b28..23db95c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +# Changelog for Money v3.2.3 + +This is the changelog for Money v3.2.3 released on February 12th, 2019. For older changelogs please consult the release tag on [GitHub](https://github.com/kipcole9/money/tags) + +### Bug Fixes + +* Correctly parse money strings with unicode currency symbols like "€". Closes #95. Thanks to @crbelaus. + # Changelog for Money v3.2.2 This is the changelog for Money v3.2.2 released on February 10th, 2019. For older changelogs please consult the release tag on [GitHub](https://github.com/kipcole9/money/tags) diff --git a/lib/money.ex b/lib/money.ex index a4c05c9..f6186d9 100644 --- a/lib/money.ex +++ b/lib/money.ex @@ -409,7 +409,7 @@ defmodule Money do # @doc since: "3.2.0" @currency "[^0-9,. ]*" @amount "[0-9][0-9,. ]+" - @regex Regex.compile!("^(?#{@currency})?(?#{@amount})?(?#{@currency})?$") + @regex Regex.compile!("^(?#{@currency})?(?#{@amount})?(?#{@currency})?$", [:unicode]) @spec parse(String.t(), Keyword.t()) :: Money.t() | {:error, {Exception.t(), String.t()}} def parse(string, options \\ []) diff --git a/mix.exs b/mix.exs index dde5f71..ab13875 100644 --- a/mix.exs +++ b/mix.exs @@ -1,7 +1,7 @@ defmodule Money.Mixfile do use Mix.Project - @version "3.2.2" + @version "3.2.3" def project do [ diff --git a/test/money_parse_test.exs b/test/money_parse_test.exs index 3b406ff..542c677 100644 --- a/test/money_parse_test.exs +++ b/test/money_parse_test.exs @@ -27,6 +27,10 @@ defmodule MoneyTest.Parse do assert Money.parse("100,00USD", locale: "de") == Money.new(:USD, "100.00") end + test "parses euro (unicode symbol)" do + assert Money.parse("99.99€") == Money.new(:EUR, "99.99") + end + test "parsing fails" do assert Money.parse("100") == {:error,