Special chars in Microsoft SQL Server and Ecto TDS

I am using Ecto and Tds to fetch a Microsoft SQL Server data. This database includes some fields with special chars like “ñ”. Fetching that field using Ecto and Tds provides a binary value instead of a legible String. Database collation is Modern_Spanish_CI_AI and I was testing to add encoding and collation options on Ecto Repo configuration but It does not work. According to documentation, Tds provides an automatica encode / decode but this is not working for my case.

I mean, the database field value is “FANDIÑO” and the Ecto query result includes this:
<<77, 65, 82, 73, 65, 32, 67, 65, 78, 79, 83, 65, 32, 70, 65, 78, 68, 73, 209, 79>> instead of legible String FANDIÑO.

The only way It works is including a manual binary to string conversion through a custom code like this one but as I said, this is supposed to be done automatically by Ecto TDS.

  def binary_to_string(binary) do
    |> :binary.bin_to_list()
    |> List.to_string()

Any help?

I think I found a solution. As of TDS version >= 1.2, tds can support windows codepages other than windows-1252 (latin1). If you need such support you will need to include additional dependency {:excoding, "~> 0.1"} and configure :tds app to use Excoding module like this:

import Mix.Config 

config :tds, :text_encoder, Excoding