-
Notifications
You must be signed in to change notification settings - Fork 60
Open
Description
Hi! 👋
Firstly, thanks for your work on this project! 🙂
Today I used patch-package to patch sybase@1.2.3 for the project I'm working on.
The parameters as strings holding international characters were causing issues in procedures.
Here is the diff that solved my problem:
diff --git a/node_modules/sybase/src/SybaseDB.js b/node_modules/sybase/src/SybaseDB.js
index 5b825ea..d91335b 100644
--- a/node_modules/sybase/src/SybaseDB.js
+++ b/node_modules/sybase/src/SybaseDB.js
@@ -38,7 +38,8 @@ Sybase.prototype.log = function(msg)
Sybase.prototype.connect = function(callback)
{
var that = this;
- this.javaDB = spawn('java',["-jar",this.pathToJavaBridge, this.host, this.port, this.dbname, this.username, this.password]);
+ // force Java to use UTF-8 charset for stdin/stdout handling so Unicode is preserved
+ this.javaDB = spawn('java',["-Dfile.encoding=UTF-8","-jar",this.pathToJavaBridge, this.host, this.port, this.dbname, this.username, this.password]);
var hrstart = process.hrtime();
this.javaDB.stdout.once("data", function(data) {
@@ -99,7 +100,8 @@ Sybase.prototype.query = function(sql, callback)
this.currentMessages[msg.msgId] = msg;
- this.javaDB.stdin.write(strMsg + "\n");
+ // write with explicit encoding to ensure characters like i18n letters are encoded as UTF-8
+ this.javaDB.stdin.write(strMsg + "\n", this.encoding);
this.log("sql request written: " + strMsg);
};
This issue body was partially generated by patch-package.
Metadata
Metadata
Assignees
Labels
No labels