Skip to content

Commit d6c36fa

Browse files
author
Benjamin Pasero
committed
debt - remove unused encoding method
1 parent bd6ac7e commit d6c36fa

2 files changed

Lines changed: 3 additions & 6 deletions

File tree

src/vs/base/node/encoding.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,6 @@ export function toDecodeStream(readable: Readable, options: IDecodeStreamOptions
138138
});
139139
}
140140

141-
export function decode(buffer: Buffer, encoding: string): string {
142-
return iconv.decode(buffer, toNodeEncoding(encoding));
143-
}
144-
145141
export function encodingExists(encoding: string): boolean {
146142
return iconv.encodingExists(toNodeEncoding(encoding));
147143
}
@@ -154,7 +150,7 @@ export function encodeStream(encoding: string, options?: { addBOM?: boolean }):
154150
return iconv.encodeStream(toNodeEncoding(encoding), options);
155151
}
156152

157-
function toNodeEncoding(enc: string | null): string {
153+
export function toNodeEncoding(enc: string | null): string {
158154
if (enc === UTF8_with_bom || enc === null) {
159155
return UTF8; // iconv does not distinguish UTF 8 with or without BOM, so we need to help it
160156
}

src/vs/base/test/node/encoding/encoding.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import * as fs from 'fs';
88
import * as encoding from 'vs/base/node/encoding';
99
import * as terminalEncoding from 'vs/base/node/terminalEncoding';
1010
import { Readable } from 'stream';
11+
import * as iconv from 'iconv-lite';
1112
import { getPathFromAmdModule } from 'vs/base/common/amd';
1213

1314
export async function detectEncodingByBOM(file: string): Promise<typeof encoding.UTF16be | typeof encoding.UTF16le | typeof encoding.UTF8_with_bom | null> {
@@ -224,7 +225,7 @@ suite('Encoding', () => {
224225
if (err) {
225226
reject(err);
226227
} else {
227-
resolve(encoding.decode(data, fileEncoding!));
228+
resolve(iconv.decode(data, encoding.toNodeEncoding(fileEncoding!)));
228229
}
229230
});
230231
});

0 commit comments

Comments
 (0)