livehelpnow / tds_ecto

TDS Adapter for Ecto
57 stars 34 forks source link

Unable to set encoding on the repo #54

Closed kh0r closed 6 years ago

kh0r commented 7 years ago

According to your documentation it's possible to set the encoding on the repo: https://github.com/livehelpnow/tds_ecto/blob/74e020f04520567b4171cc7c3c03a25ebafe99b4/lib/tds_ecto.ex#L49

This doesn't seem to work for me. No matter what I write as value, I get wrongly encoded data.

This should imho be the correct config:

config :ciq, Ciq.SourceRepo,
  adapter: Tds.Ecto,
  encoding: "latin-1",
  ...

e.g. the string Curaçao gets read as <<67, 117, 114, 97, 231, 97, 111>> but should be read as <<67, 117, 114, 97, 195, 167, 97, 111>>

mjaric commented 7 years ago

Hi @kh0r

Sorry for delayed response. I'm not sure if that worked so far, it is UTF-8 always, I will check old 1.X version to see if there was any functions which did any other encoding. I know that current codebase do not have anything which used that configuration flag, it simply converts bitstring to ucs-2 binary. If I'm not wrong nvarchar should keep you safe here, so if you are using nvarchar columns you should get correct string back to the client app.

Finally, could you please let me know if example you showed in issue, is that something you tried to store in varchar column?