Skip to content

Commit bbe787a

Browse files
author
Benjamin Pasero
committed
encoding - add test for microsoft#102202
1 parent 372470a commit bbe787a

2 files changed

Lines changed: 997 additions & 0 deletions

File tree

src/vs/workbench/services/textfile/test/node/encoding/encoding.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,20 @@ suite('Encoding', () => {
353353
assert.equal(content.length, 65537);
354354
});
355355

356+
test('toDecodeStream - some stream (UTF-8 issue #102202)', async function () {
357+
const path = getPathFromAmdModule(require, './fixtures/issue_102202.txt');
358+
const source = streamToBufferReadableStream(fs.createReadStream(path));
359+
360+
const { detected, stream } = await encoding.toDecodeStream(source, { minBytesRequiredForDetection: 4, guessEncoding: false, overwriteEncoding: async () => 'utf-8' });
361+
assert.ok(detected);
362+
assert.ok(stream);
363+
364+
const content = await readAllAsString(stream);
365+
const lines = content.split('\n');
366+
367+
assert.equal(lines[981].toString(), '啊啊啊啊啊啊aaa啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊,啊啊啊啊啊啊啊啊啊啊啊。');
368+
});
369+
356370
test('toEncodeReadable - encoding, utf16be', async function () {
357371
const path = getPathFromAmdModule(require, './fixtures/some_utf16be.css');
358372
const source = await readAndDecodeFromDisk(path, encoding.UTF16be);

0 commit comments

Comments
 (0)