mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-04-30 04:30:48 +00:00
fix: preserve original encoding when reading/writing non-UTF-8 files
Fixes #2069 - Add iconv-lite dependency for non-UTF-8 encoding support - Add iconvHelper.ts as a CJS/ESM compatibility wrapper - Update readFileWithEncoding() to detect and handle GBK/Big5/Shift_JIS using BOM detection -> UTF-8 validation -> chardet -> iconv-lite fallback - Add detectFileEncoding() to identify file encoding before writes - Update writeTextFile() to accept encoding option and encode with iconv-lite - Update WriteFileTool and EditTool to detect and preserve original encoding - Add tests for GBK read/write, detectFileEncoding, and encoding option
This commit is contained in:
parent
407a66c959
commit
a5eb1733fa
11 changed files with 375 additions and 32 deletions
|
|
@ -57,7 +57,7 @@ export class AcpFileSystemService implements FileSystemService {
|
|||
async writeTextFile(
|
||||
filePath: string,
|
||||
content: string,
|
||||
options?: { bom?: boolean },
|
||||
options?: { bom?: boolean; encoding?: string },
|
||||
): Promise<void> {
|
||||
if (!this.capabilities.writeTextFile) {
|
||||
return this.fallback.writeTextFile(filePath, content, options);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue