Update pipe-ipc.js

This commit is contained in:
Namhyeon Go 2023-09-20 14:32:27 +09:00 committed by GitHub
parent 01cfdb0f72
commit 04ec2586a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -69,6 +69,18 @@ function createADO() {
return CreateObject("ADODB.Stream");
}
function SetPositionADO(ado, position) {
var newAdo = createADO();
newAdo.Type = adTypeBinary;
newAdo.Mode = adModeReadWrite;
newAdo.Open();
ado.Position = position;
ado.CopyTo(newAdo);
ado.Flush();
ado.Close();
return newAdo;
}
function PipeIPC() {
this.path = "data\\.pipe_:pipename";
this.delimiter = "\r\n";
@ -237,19 +249,6 @@ function PipeIPC() {
var charset = this.charset;
var isCommited = false;
// define functions
var StripAdoBOM = function(adoObj) {
var newAdoObj = createADO();
newAdoObj.Type = adTypeBinary;
newAdoObj.Mode = adModeReadWrite;
newAdoObj.Open();
adoObj.Position = 3;
adoObj.CopyTo(newAdoObj);
adoObj.Flush();
adoObj.Close();
return newAdoObj;
};
while (!isCommited) {
try {
// Open a temporary file
@ -268,13 +267,13 @@ function PipeIPC() {
str = text;
}
// Convert UTF-16 BOM to UTF-8
// Convert UTF-16 BOM to a character set
var ado = createADO();
ado.Type = adTypeText;
ado.Charset = charset;
ado.Open();
ado.WriteText(str);
ado = StripAdoBOM(ado);
ado = SetPositionADO(ado, 3);
ado.SaveToFile(dst, adSaveCreateOverWrite);
ado.Close();