{"record":{"id":"e757f102fc65e551","repo":"studyzy/imewlconverter","slug":"line","errorCode":null,"errorMessage":"无效的自定义编码格式：{line}","messagePattern":"无效的自定义编码格式：(.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/ImeWlConverter.Core/Helpers/UserCodingHelper.cs","lineNumber":22,"sourceCode":"\npublic static class UserCodingHelper\n{\n    public static IDictionary<char, IList<string>> GetCodingDict(\n        string filePath,\n        Encoding encoding\n    )\n    {\n        var codingContent = FileOperationHelper.ReadFile(filePath, encoding);\n        var dic = new Dictionary<char, IList<string>>();\n        foreach (\n            var line in codingContent.Split(\n                new[] { '\\r', '\\n' },\n                StringSplitOptions.RemoveEmptyEntries\n            )\n        )\n        {\n            var l = line.Split('\\t');\n            if (l.Length != 2) throw new Exception(\"无效的自定义编码格式：\" + line);\n            var c = l[0][0];\n            var code = l[1];\n            if (!dic.ContainsKey(c))\n                dic.Add(c, new List<string> { code });\n            else\n                dic[c].Add(code);\n        }\n\n        return dic;\n    }\n}\n","sourceCodeStart":4,"sourceCodeEnd":34,"githubUrl":"https://github.com/studyzy/imewlconverter/blob/16744a12ed5064896cf39095163e44b367aaada1/src/ImeWlConverter.Core/Helpers/UserCodingHelper.cs#L4-L34","documentation":"UserCodingHelper.GetCodingDict loads a user-supplied custom code-mapping file for the user-defined coding generator. Each non-empty line MUST be exactly two tab-separated fields (character, code). Any line that does not split into exactly 2 tab-fields throws, reporting the offending line.","triggerScenarios":"A custom coding file using spaces, commas, or multiple tabs instead of exactly one tab as delimiter; a line with a single field; a line with three or more tab fields; a stray trailing tab that creates an empty third field.","commonSituations":"User hand-edited the mapping file and used spaces instead of tabs; file exported from Excel/spreadsheet as CSV rather than TSV; mixed delimiters; a comment line that survived the empty-line removal.","solutions":["Open the file and confirm every line is exactly `char<TAB>code` with a single tab and no trailing tab.","Convert any space/comma delimiters to a single tab; remove stray tabs.","If a different delimiter is intended, pre-process the file to tab-separated before passing it in."],"exampleFix":"// before (file content, space-delimited)\n// a b\n// after (tab-delimited)\n// a\\tb","handlingStrategy":"validation","validationCode":"foreach (var line in lines)\n    if (line.Split('\\t').Length != 2)\n        throw new FormatException($\"bad line (expected 1 tab): {line}\");","typeGuard":null,"tryCatchPattern":"try { var dic = UserCodingHelper.GetCodingDict(path, enc); }\ncatch (Exception ex) { ReportError($\"custom coding file invalid: {ex.Message}\"); }","preventionTips":["Document the exact TSV format (one tab, two fields) for user coding files.","Dry-run validate the file (count tabs per line) before the full conversion.","Normalize delimiters (spaces/commas to a single tab) in a pre-processing step."],"tags":["custom-coding","parsing","user-input","config"],"backgroundTag":null,"analyzedSha":"16744a12ed5064896cf39095163e44b367aaada1","analyzedAt":"2026-08-13T19:53:09.031Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}