diff --git a/lib/elixir/lib/string.ex b/lib/elixir/lib/string.ex index 0fce4b87ed2..a2f92756538 100644 --- a/lib/elixir/lib/string.ex +++ b/lib/elixir/lib/string.ex @@ -505,13 +505,13 @@ defmodule String do ## Examples iex> String.normalize("yêṩ", :nfd) - "yêṩ" + "yêṩ" iex> String.normalize("leña", :nfc) "leña" """ - @spec normalize(t, atom) :: boolean + @spec normalize(t, atom) :: t defdelegate normalize(string, form), to: String.Normalizer @doc """ diff --git a/lib/elixir/test/elixir/string_test.exs b/lib/elixir/test/elixir/string_test.exs index f5c82a215ab..07033799be5 100644 --- a/lib/elixir/test/elixir/string_test.exs +++ b/lib/elixir/test/elixir/string_test.exs @@ -378,7 +378,7 @@ defmodule StringTest do test "normalize" do assert String.normalize("ŝ", :nfd) == "ŝ" - assert String.normalize("ḇravô", :nfd) == "ḇravô" + assert String.normalize("ḇravô", :nfd) == "ḇravô" assert String.normalize("ṩierra", :nfd) == "ṩierra" assert String.normalize("뢴", :nfd) == "뢴" assert String.normalize("êchǭ", :nfc) == "êchǭ" diff --git a/lib/elixir/unicode/unicode.ex b/lib/elixir/unicode/unicode.ex index f8e566a7e8a..360388f91b3 100644 --- a/lib/elixir/unicode/unicode.ex +++ b/lib/elixir/unicode/unicode.ex @@ -505,7 +505,7 @@ defmodule String.Normalizer do {n, rest} = String.Unicode.next_grapheme_size(binary) part = :binary.part(binary, 0, n) case n do - 1 -> normalize_nfc(rest, acc <> part) + 1 -> normalize_nfd(rest, acc <> part) _ -> normalize_nfd(rest, acc <> canonical_order(part, [])) end end