Skip to content

.run with a utf-8 script with unicode strings does wrong conversion #56

Open
@etiennellipse

Description

@etiennellipse

Version: 0.6.2
MacOS 10.14.4
Node v10.15.2

I have a SQL script encoded in UTF-8 that contains insert statements with unicode strings that are inserting in a NVARCHAR field. When I run this script, the data inserted in the table is malformed.

Example:

CREATE TABLE homeInstitution
(
    id INT IDENTITY(0,1) NOT NULL PRIMARY KEY,
    institution NVARCHAR(128) NOT NULL,
    deletedDate DATETIME NULL,
);

INSERT [dbo].[homeInstitution] ([institution], [deletedDate]) VALUES (N'Lycée ÀÉÙÇÊÏ', NULL)
  1. Save this into a UTF-8 encoded file
  2. Connect to mssql, run the script: .run myfile.sql
  3. select * from homeInstitution

Result:

mssql> select * from homeInstitution;
id  institution    deletedDate
--  -------------  -----------
0   Lycée ������  null

1 row(s) returned
  • If I convert the file to ISO-8859-1 format, the data is inserted correctly

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions