|
1 diff --git a/src/vs/workbench/services/textfile/common/encoding.ts b/src/vs/workbench/services/textfile/common/encoding.ts |
|
2 --- a/src/vs/workbench/services/textfile/common/encoding.ts |
|
3 +++ b/src/vs/workbench/services/textfile/common/encoding.ts |
|
4 @@ -6,6 +6,7 @@ |
|
5 import { Readable, ReadableStream, newWriteableStream, listenStream } from 'vs/base/common/stream'; |
|
6 import { VSBuffer, VSBufferReadable, VSBufferReadableStream } from 'vs/base/common/buffer'; |
|
7 import { IDisposable } from 'vs/base/common/lifecycle'; |
|
8 +import * as isabelle_encoding from './isabelle_encoding'; |
|
9 |
|
10 export const UTF8 = 'utf8'; |
|
11 export const UTF8_with_bom = 'utf8bom'; |
|
12 @@ -78,7 +79,9 @@ class DecoderStream implements IDecoderStream { |
|
13 */ |
|
14 static async create(encoding: string): Promise<DecoderStream> { |
|
15 let decoder: IDecoderStream | undefined = undefined; |
|
16 - if (encoding !== UTF8) { |
|
17 + if (encoding === isabelle_encoding.ENCODING) { |
|
18 + decoder = isabelle_encoding.getDecoder(); |
|
19 + } else if (encoding !== UTF8) { |
|
20 const iconv = await import('@vscode/iconv-lite-umd'); |
|
21 decoder = iconv.getDecoder(toNodeEncoding(encoding)); |
|
22 } else { |
|
23 @@ -212,7 +215,9 @@ export function toDecodeStream(source: VSBufferReadableStream, options: IDecodeS |
|
24 |
|
25 export async function toEncodeReadable(readable: Readable<string>, encoding: string, options?: { addBOM?: boolean }): Promise<VSBufferReadable> { |
|
26 const iconv = await import('@vscode/iconv-lite-umd'); |
|
27 - const encoder = iconv.getEncoder(toNodeEncoding(encoding), options); |
|
28 + const encoder = |
|
29 + encoding === isabelle_encoding.ENCODING ? |
|
30 + isabelle_encoding.getEncoder() : iconv.getEncoder(toNodeEncoding(encoding), options); |
|
31 |
|
32 let bytesWritten = false; |
|
33 let done = false; |
|
34 @@ -262,7 +267,7 @@ export async function toEncodeReadable(readable: Readable<string>, encoding: str |
|
35 export async function encodingExists(encoding: string): Promise<boolean> { |
|
36 const iconv = await import('@vscode/iconv-lite-umd'); |
|
37 |
|
38 - return iconv.encodingExists(toNodeEncoding(encoding)); |
|
39 + return encoding === isabelle_encoding.ENCODING || iconv.encodingExists(toNodeEncoding(encoding)); |
|
40 } |
|
41 |
|
42 export function toNodeEncoding(enc: string | null): string { |
|
43 @@ -479,6 +484,11 @@ export function detectEncodingFromBuffer({ buffer, bytesRead }: IReadResult, aut |
|
44 } |
|
45 |
|
46 export const SUPPORTED_ENCODINGS: { [encoding: string]: { labelLong: string; labelShort: string; order: number; encodeOnly?: boolean; alias?: string } } = { |
|
47 + utf8isabelle: { |
|
48 + labelLong: isabelle_encoding.LABEL, |
|
49 + labelShort: isabelle_encoding.LABEL, |
|
50 + order: 0, |
|
51 + }, |
|
52 utf8: { |
|
53 labelLong: 'UTF-8', |
|
54 labelShort: 'UTF-8', |