Badly encoded characters output when querying sys.extended_properties
Hi guys,
I'm getting badly encoded chars specifically when I use the sys.extended_properties table.
I get german: f�r instead of für, Integrit�t for Integrität
Using this code as a test :
const sql = require('mssql');
const fs = require("node:fs");
(async () => {
try {
// make sure that any items are correctly URL encoded in the connection string
await sql.connect('...')
const result = await sql.query`SELECT top 10 * FROM sys.extended_properties`
fs.writeFileSync('extended-properties.json', JSON.stringify(result , null, 2));
} catch (err) {
console.error(err);
}
})()
On all other user tables, there are no encoding problems
My DB collation is Latin1_General_CI_AI
Any idea ?
- What version of the library is this relating to?
- What debugging steps have you taken so far?
- Can you fetch the data encoded correctly via another means?
- How did you put the data in? Do you have minimal reproduction example?
I've tested using the simple code above. It's using mssql version 11.0.1
Changing the driver to msnodesqlv8 resolves the problem
const sql = require('mssql/msnodesqlv8');
To reproduce I'm inserting into extended_properties using the MS stored procedure : https://learn.microsoft.com/en-us/sql/relational-databases/system-stored-procedures/sp-addextendedproperty-transact-sql?view=sql-server-ver16
USE AdventureWorks2022;
GO
EXEC sys.sp_addextendedproperty @name = N'MS_Description',
@value = N'Stadtführungen auf deutsch.',
@level0type = 'SCHEMA', @level0name = N'Person',
@level1type = 'TABLE', @level1name = N'Address';
GO
Changing the driver to msnodesqlv8 resolves the problem
that indicates that this may be a problem in the tedious driver, then. If you use just the driver and not the mssql lib, do you have the same problem?
Oh… didn’t know I could do that. Can you give me a hint on how I can try this ?
Just using the underlying library directly: https://github.com/tediousjs/tedious
So yes, I can reproduce using the tedious library only (v18.6.1)
// using system extended_properties view
const query = 'SELECT value FROM sys.extended_properties WHERE major_id= 50099219 AND minor_id = 6' ;
// ouputs Stadtf�hrungen auf deutsch."
// using any normal user table
const query= 'SELECT plainText FROM Notes' ;
// ouputs "Stadtführungen auf deutsch."
Should I transfer this issue somewhere else ?
Hmm - I tried transferring the issue to tedious but it didn't work. Would you mind opening a new one there and we can close this as an upstream bug.