{"record":{"id":"d654aa8812d34546","repo":"studyzy/imewlconverter","slug":"userwordbase-filesize","errorCode":null,"errorMessage":"词库文件格式不正确,文件大小至少需要{UserWordBase}字节,当前为{fileSize}字节","messagePattern":"词库文件格式不正确,文件大小至少需要(.+?)字节,当前为(.+?)字节","errorType":"exception","errorClass":"InvalidDataException","httpStatus":null,"severity":"error","filePath":"src/ImeWlConverter.Formats/Win10MsSelfStudy/Win10MsPinyinSelfStudyImporter.cs","lineNumber":22,"sourceCode":"using ImeWlConverter.Abstractions;\nusing ImeWlConverter.Abstractions.Enums;\nusing ImeWlConverter.Abstractions.Models;\nusing ImeWlConverter.Formats.Shared;\n\n/// <summary>Win10 Microsoft Pinyin self-study dictionary importer (binary DAT format).</summary>\n[FormatPlugin(\"win10mspyss\", \"Win10微软拼音（自学习词汇）\", 130)]\npublic sealed partial class Win10MsPinyinSelfStudyImporter : BinaryFormatImporter\n{\n    private const int UserWordBase = 0x2400;\n    private const int EntrySize = 60;\n\n    protected override IReadOnlyList<WordEntry> ParseBinary(Stream input, CancellationToken ct)\n    {\n        var results = new List<WordEntry>();\n        var fileSize = input.Length;\n\n        if (fileSize < UserWordBase)\n            throw new InvalidDataException(\n                $\"词库文件格式不正确,文件大小至少需要{UserWordBase}字节,当前为{fileSize}字节\");\n\n        // Read word count at offset 12\n        input.Position = 12;\n        var countBytes = new byte[4];\n        input.ReadExactly(countBytes, 0, 4);\n        var cnt = BitConverter.ToInt32(countBytes, 0);\n\n        if (cnt < 0 || cnt > 100000)\n            throw new InvalidDataException($\"词条数量异常: {cnt},可能是文件格式不兼容\");\n\n        for (var i = 0; i < cnt; i++)\n        {\n            ct.ThrowIfCancellationRequested();\n\n            var curIdx = UserWordBase + i * EntrySize;\n\n            if (curIdx + EntrySize > fileSize)","sourceCodeStart":4,"sourceCodeEnd":40,"githubUrl":"https://github.com/studyzy/imewlconverter/blob/16744a12ed5064896cf39095163e44b367aaada1/src/ImeWlConverter.Formats/Win10MsSelfStudy/Win10MsPinyinSelfStudyImporter.cs#L4-L40","documentation":"Win10MsPinyinSelfStudyImporter requires the DAT file to be at least 0x2400 (9216) bytes because the word-data region begins at that fixed offset. A smaller file cannot be a valid self-study dictionary, so the importer aborts immediately with InvalidDataException before reading any entries.","triggerScenarios":"Feeding a small/non-DAT file (e.g. a few hundred bytes) as the win10mspyss format; a truncated copy of the self-study .dat; a file from a different Microsoft IME format that is coincidentally tiny.","commonSituations":"Wrong file/format chosen; a partial copy of the self-study .dat (normally under %AppData%); confusing this format with the regular Win10 Microsoft Pinyin user dictionary.","solutions":["Verify the file is the Win10 self-study .dat and is at least 9216 bytes before importing.","Re-export or re-copy the file completely from the IME data directory.","Select the correct importer matching the actual file type (e.g. the standard win10mspy importer for the regular user dict)."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if (new FileInfo(path).Length < 0x2400)\n    ReportError(\"not a valid win10mspyss file (too small)\");","typeGuard":null,"tryCatchPattern":"try { var entries = importer.ParseBinary(stream, ct); }\ncatch (InvalidDataException ex) { ReportError(ex.Message); }","preventionTips":["Confirm the file source and minimum size (9216 bytes) before importing.","Use the IME's own data directory to locate the real self-study .dat.","Do not confuse this format with the regular Win10 MS Pinyin user dictionary."],"tags":["win10","mspy","binary","import","validation"],"backgroundTag":null,"analyzedSha":"16744a12ed5064896cf39095163e44b367aaada1","analyzedAt":"2026-08-13T19:53:09.031Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}