codepagex icon indicating copy to clipboard operation
codepagex copied to clipboard

Inconsistent "from_string/4" return types

Open airton-soares opened this issue 4 years ago • 1 comments

Hello.

I was testing some of the functions of the main module and found out that the returned types from from_string/4 are not always as shown in the documentation. Here some exemple:

iex(9)> from_string("Água", :ascii, replace_nonexistent(""))     
{:ok, "gua", 1}
iex(10)> from_string("Água", :iso_8859_1, replace_nonexistent(""))
{:ok, <<193, 103, 117, 97>>, nil}

Using the :iso_8859_1 encoding a binary is returned but with the ascii a string is returned. Is that the right behaviour?

airton-soares avatar Mar 15 '22 19:03 airton-soares

I believe both results have binary types, its just how Elixir will print them that differs

tallakt avatar Mar 15 '22 21:03 tallakt