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