mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-01 01:25:38 -05:00
Merge from vscode a5cf1da01d5db3d2557132be8d30f89c38019f6c (#8525)
* Merge from vscode a5cf1da01d5db3d2557132be8d30f89c38019f6c * remove files we don't want * fix hygiene * update distro * update distro * fix hygiene * fix strict nulls * distro * distro * fix tests * fix tests * add another edit * fix viewlet icon * fix azure dialog * fix some padding * fix more padding issues
This commit is contained in:
@@ -9,7 +9,7 @@ import * as encoding from 'vs/base/node/encoding';
|
||||
import { Readable } from 'stream';
|
||||
import { getPathFromAmdModule } from 'vs/base/common/amd';
|
||||
|
||||
export async function detectEncodingByBOM(file: string): Promise<string | null> {
|
||||
export async function detectEncodingByBOM(file: string): Promise<typeof encoding.UTF16be | typeof encoding.UTF16le | typeof encoding.UTF8_with_bom | null> {
|
||||
try {
|
||||
const { buffer, bytesRead } = await readExactlyByFile(file, 3);
|
||||
|
||||
@@ -86,7 +86,7 @@ suite('Encoding', () => {
|
||||
const file = getPathFromAmdModule(require, './fixtures/some_utf8.css');
|
||||
|
||||
const detectedEncoding = await detectEncodingByBOM(file);
|
||||
assert.equal(detectedEncoding, 'utf8');
|
||||
assert.equal(detectedEncoding, 'utf8bom');
|
||||
});
|
||||
|
||||
test('detectBOM UTF-16 LE', async () => {
|
||||
@@ -189,6 +189,20 @@ suite('Encoding', () => {
|
||||
assert.equal(mimes.seemsBinary, false);
|
||||
});
|
||||
|
||||
test('autoGuessEncoding (UTF8)', async function () {
|
||||
const file = getPathFromAmdModule(require, './fixtures/some_file.css');
|
||||
const buffer = await readExactlyByFile(file, 512 * 8);
|
||||
const mimes = await encoding.detectEncodingFromBuffer(buffer, true);
|
||||
assert.equal(mimes.encoding, 'utf8');
|
||||
});
|
||||
|
||||
test('autoGuessEncoding (ASCII)', async function () {
|
||||
const file = getPathFromAmdModule(require, './fixtures/some_ansi.css');
|
||||
const buffer = await readExactlyByFile(file, 512 * 8);
|
||||
const mimes = await encoding.detectEncodingFromBuffer(buffer, true);
|
||||
assert.equal(mimes.encoding, null);
|
||||
});
|
||||
|
||||
test('autoGuessEncoding (ShiftJIS)', async function () {
|
||||
const file = getPathFromAmdModule(require, './fixtures/some.shiftjis.txt');
|
||||
const buffer = await readExactlyByFile(file, 512 * 8);
|
||||
|
||||
Reference in New Issue
Block a user