studyzy/imewlconverter · error · InvalidDataException
未能成功解析任何词条,可能是文件格式不兼容或文件已损坏
Error message
未能成功解析任何词条,可能是文件格式不兼容或文件已损坏
What it means
After looping over all candidate entries, if NOT A SINGLE word was successfully parsed (results.Count == 0) the importer throws InvalidDataException. The file passed the size and count checks, but every entry was skipped (invalid word length, or out-of-bounds) — i.e. a format that looks structurally plausible at the header level but whose per-entry 60-byte layout does not match.
Source
Thrown at src/ImeWlConverter.Formats/Win10MsSelfStudy/Win10MsPinyinSelfStudyImporter.cs:83
var pyIndex = BitConverter.ToInt16(pyIndexBytes, 0);
if (pyIndex >= 0 && pyIndex < PinyinTable.Length)
pinyin[j] = PinyinTable[pyIndex];
else
pinyin[j] = "a";
}
results.Add(new WordEntry
{
Word = word,
Rank = 0,
CodeType = CodeType.Pinyin,
Code = WordCode.FromSingle(pinyin)
});
}
if (results.Count == 0)
throw new InvalidDataException("未能成功解析任何词条,可能是文件格式不兼容或文件已损坏");
return results;
}
internal static readonly string[] PinyinTable =
{
"a", "ai", "an", "ang", "ao",
"ba", "bai", "ban", "bang", "bao", "bei", "ben", "beng", "bi", "bian",
"biao", "bie", "bin", "bing", "bo", "bu",
"ca", "cai", "can", "cang", "cao", "ce", "cen", "ceng",
"cha", "chai", "chan", "chang", "chao", "che", "chen", "cheng", "chi",
"chong", "chou", "chu", "chua", "chuai", "chuan", "chuang", "chui", "chun", "chuo",
"ci", "cong", "cou", "cu", "cuan", "cui", "cun", "cuo",
"da", "dai", "dan", "dang", "dao", "de", "dei", "den", "deng", "di",
"dia", "dian", "diao", "die", "ding", "diu", "dong", "dou", "du", "duan",
"dui", "dun", "duo",
"e", "ei", "en", "eng", "er",
"fa", "fan", "fang", "fei", "fen", "feng", "fiao", "fo", "fou", "fu",View on GitHub (pinned to 16744a12ed)
Solutions
- Confirm the Windows/Office version that produced the file matches what the importer supports.
- Re-export the self-study .dat from a supported IME build.
- If developing the importer, verify the entry offsets (curIdx+10 for length, curIdx+12 for word, EntrySize=60) against the actual format of the producing build.
Defensive patterns
Strategy: try-catch
Try / catch
try { var entries = importer.ParseBinary(stream, ct); }
catch (InvalidDataException ex) { ReportError($"no entries parsed, likely version mismatch: {ex.Message}"); } Prevention
- Match the Windows/Office build that produced the file to what the importer supports.
- Keep a known-good self-study sample to regression-test entry offsets.
- When developing, verify curIdx+10 (length) and curIdx+12 (word) against the real format.
When it happens
Trigger: A file >= 9216 bytes with a plausible count, but the per-entry layout (word length at curIdx+10, word bytes at curIdx+12, 60-byte stride) does not match — e.g. an incompatible Windows/Office build's self-study format where the entry offsets shifted.
Common situations: Windows or Office version mismatch that changed the internal entry layout; a partially-compatible file that fools the header checks but fails every entry parse; a corrupt file whose count is plausible but entry region is damaged.
Related errors
AI-assisted analysis of studyzy/imewlconverter@16744a12ed (2026-08-13).
Data as JSON: /api/errors/fb1d09b599ed2a49.
Report an issue: GitHub.