src/vs/workbench/services/textfile/common/textFileEditorModel.ts/TextFileEditorModel/setEncoding
class TextFileEditorModel:	async setEncoding(encoding: string, mode: EncodingMode): Promise<void> {
		if (!this.isNewEncoding(encoding)) {
			return; // return early if the encoding is already the same
		}

		// Encode: Save with encoding
		if (mode === EncodingMode.Encode) {
			this.updatePreferredEncoding(encoding);

			// Save
			if (!this.isDirty()) {
				this.versionId++; // needs to increment because we change the model potentially
				this.setDirty(true);
			}

			if (!this.inConflictMode) {
				await this.save();
			}
		}

		// Decode: Resolve with encoding
		else {
			if (this.isDirty()) {
				await this.save();
			}

			this.updatePreferredEncoding(encoding);

			await this.resolve({
				forceReadFromFile: true	// because encoding has changed
			});
		}
	}