Files
MemRelay/projects/8e229c96-a83b-4a02-ac40-10a0a9da444e/CSV 编码自动识别不能只靠 GBK 解码报错.md
T

1.1 KiB

title, type, permalink, stable_id, scope, memory_type, project_id, usage_profile_id, status, revision, request_id, created_at, updated_at, tags
title type permalink stable_id scope memory_type project_id usage_profile_id status revision request_id created_at updated_at tags
CSV 编码自动识别不能只靠 GBK 解码报错 experience main/projects/8e229c96-a83b-4a02-ac40-10a0a9da444e/csv-编码自动识别不能只靠-gbk-解码报错 ffa069f7-a3c2-4acc-a4ec-fef9b5f87c80 project experience 8e229c96-a83b-4a02-ac40-10a0a9da444e 7aee455b-24cc-4008-bdaf-443721e6f939 active 1 exp-csv-encoding-autodetect 2026-09-17T01:38:38.591136+00:00 2026-09-17T01:38:38.591136+00:00
encoding
buildings

GetNRBuildingsData.detect_encoding(path, preferred):读 1MB 样本,按最后换行截断;有 BOM 或含非 ASCII 且能严格 UTF-8 解码 → utf-8-sig,否则 gbk;纯 ASCII 用首选;再验表头 WKT/building_id,不行就试其余候选,都不行才报错。原因:GBK 对 UTF-8 字节很宽容,不能靠解码报错判断。validation 把判定结果写回 params[INPUT_ENCODING] 供 worker 使用。当前 source/NRBuildPolygon.csv 实际为纯 ASCII(无 BOM),gbk/utf-8 等价。