You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In our company we are currently using Eclipse as official IDE.
We are in the process to also try other IDEs, and vscode is a desiderable one we would like to promote as official IDE.
Anyway, we are currently facing a problem trying to keep a strict consistency with the file encoding defined with the Eclipse's settings (this is our source of truth deciding what encoding applying to a document).
We thought that developing a vscode extension reading the Eclipse settings could suffice for this need, but we stumbled into a possible limitation vscode side.
We gave a look to the vscode APIs and we realized that it seems not to be available an API to select the encoding for the document being edited.
an approach (workaround like) could be to use this fragment when saving a document using an arbitrary encoding:
import * as vscode from 'vscode';
// Function to save a document with a specified encoding
async function saveWithEncoding(document: vscode.TextDocument, encoding: string): Promise<boolean> {
try {
await document.save({ encoding });
return true;
} catch (error) {
console.error('Error saving document:', error);
return false;
}
}
// Example usage
const activeEditor = vscode.window.activeTextEditor;
if (activeEditor) {
const document = activeEditor.document;
saveWithEncoding(document, 'utf16le'); // Example encoding
}
But this is not sufficient, we would need an API acting as the built-in function: Reopen With Encoding.
Any advice on how to achieve this with the current API set would be great; if such API does not currently exist, we could be interested into helping creating new one.
This is the issue opened explaining the need we would like to implement in the extension.
The text was updated successfully, but these errors were encountered:
giubacc
changed the title
Expose (Re)open With Econding as API
Expose (Re)open With Encoding as API
Apr 10, 2024
Thanks for creating this issue! We figured it's covering the same as another one we already have. Thus, we closed this one as a duplicate. You can search for similar existing issues. See also our issue reporting guidelines.
Hi,
In our company we are currently using Eclipse as official IDE.
We are in the process to also try other IDEs, and vscode is a desiderable one we would like to promote as official IDE.
Anyway, we are currently facing a problem trying to keep a strict consistency with the file encoding defined with the Eclipse's settings (this is our source of truth deciding what encoding applying to a document).
We thought that developing a vscode extension reading the Eclipse settings could suffice for this need, but we stumbled into a possible limitation vscode side.
We gave a look to the vscode APIs and we realized that it seems not to be available an API to select the encoding for the document being edited.
an approach (workaround like) could be to use this fragment when saving a document using an arbitrary encoding:
But this is not sufficient, we would need an API acting as the built-in function:
Reopen With Encoding
.Any advice on how to achieve this with the current API set would be great; if such API does not currently exist, we could be interested into helping creating new one.
This is the issue opened explaining the need we would like to implement in the extension.
The text was updated successfully, but these errors were encountered: