Revert "feat: 添加 GBK 编码自动检测支持,文件读写工具透明处理非 UTF-8 文件"

This reverts commit 0ce8f7a1cb.
This commit is contained in:
claude-code-best
2026-05-10 22:57:30 +08:00
parent 43c20a43c2
commit aaabf0c168
22 changed files with 120 additions and 1727 deletions

View File

@@ -1,10 +1,9 @@
import { detectFileEncoding } from './file.js'
import { type FileEncoding, decodeBuffer } from './encoding.js'
import { getFsImplementation } from './fsOperations.js'
type CachedFileData = {
content: string
encoding: FileEncoding
encoding: BufferEncoding
mtime: number
}
@@ -20,7 +19,7 @@ class FileReadCache {
* Reads a file with caching. Returns both content and encoding.
* Cache key includes file path and modification time for automatic invalidation.
*/
readFile(filePath: string): { content: string; encoding: FileEncoding } {
readFile(filePath: string): { content: string; encoding: BufferEncoding } {
const fs = getFsImplementation()
// Get file stats for cache invalidation
@@ -46,8 +45,9 @@ class FileReadCache {
// Cache miss or stale data - read the file
const encoding = detectFileEncoding(filePath)
const rawBuffer = fs.readFileBytesSync(filePath)
const content = decodeBuffer(rawBuffer, encoding).replaceAll('\r\n', '\n')
const content = fs
.readFileSync(filePath, { encoding })
.replaceAll('\r\n', '\n')
// Update cache
this.cache.set(cacheKey, {