Coder Social home page Coder Social logo

Comments (3)

ericlathrop avatar ericlathrop commented on August 16, 2024

I think I've got a similar issue with a fancy quote:

mssql-cli:

DB> select newstitle from hrdb_news where newsidentifier = 'Breeders_Cup_winner_Whitmore_sprints_to_8_year_old_campaign_123';
+--------------------------------------------------------------+
| newstitle                                                    |
|--------------------------------------------------------------|
| Breeders’ Cup winner Whitmore sprints to 8-year-old campaign |
+--------------------------------------------------------------+
(1 row affected)
Time: 0.355s
DB> select master.dbo.fn_varbintohexstr(cast(newstitle as varbinary(max))) from hrdb_news where newsidentifier = 'Breeders_Cup_winner_Whitmore_sprints_to_8_year_old_campaign_123';
-[ RECORD 1 ]-------------------------
(No column name) | 0x42007200650065006400650072007300192020004300750070002000770069006e006e0065007200200057006800690074006d006f0072006500200073007000720069006e0074007300200074006f00200038002d0079006500610072002d
(1 row affected)

where the column looks like:

+-----------------------+------------------+------------+----------+--------+---------+------------+----------------------+------------------------+------------------------------+
| Column_name           | Type             | Computed   | Length   | Prec   | Scale   | Nullable   | TrimTrailingBlanks   | FixedLenNullInSource   | Collation                    |
|-----------------------+------------------+------------+----------+--------+---------+------------+----------------------+------------------------+------------------------------|
| NewsTitle             | nvarchar         | no         | 510      |        |         | no         | (n/a)                | (n/a)                  | SQL_Latin1_General_CP1_CI_AS |

but Tds gives me:

iex(2)> IO.inspect(a.news_title, binaries: :as_strings)
"Breeders\x19  Cup winner Whitmore sprints to 8-year-old campaign"
<<66, 114, 101, 101, 100, 101, 114, 115, 25, 32, 32, 67, 117, 112, 32, 119, 105,
  110, 110, 101, 114, 32, 87, 104, 105, 116, 109, 111, 114, 101, 32, 115, 112,
  114, 105, 110, 116, 115, 32, 116, 111, 32, 56, 45, 121, 101, 97, 114, 45, 111,
  ...>>

with ecto schema:

schema "hrdb_News" do                           
  field(:news_title, :string)                   

from tds.

ericlathrop avatar ericlathrop commented on August 16, 2024

My issue was solved by setting up :tds_encoding per the instructions in the README.

from tds.

mjaric avatar mjaric commented on August 16, 2024

With erlang builtin :unicode module there is not higher compatibility between latin1 encoding and SQL_Latin1_General_CP1_CI_AS collation since some stuff is sent as ucs2 string. This ucs2 is NOT! UTF-16 nor UTF-8, ucs2 is fixed char code length (always 2 or 4 bytes long) while UTF-X is variable in char code length. If you need to store anything that has chars codes that contain higher byte other than zero you should use :tds_encoding lib

from tds.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.