Skip to content

Commit

Permalink
fix: scel 拼音索引越界
Browse files Browse the repository at this point in the history
  • Loading branch information
nopdan committed Dec 21, 2024
1 parent 3aded7f commit 9ce6aae
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 1 addition & 2 deletions src/ImeWlConverterCore/IME/QQPinyinQcel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ public WordLibraryList Import(string path)
#endregion

private Dictionary<int, string> pyDic = new Dictionary<int, string>();
private static char[] a2zchar => "abcdefghijklmnopqrstuvwxyz".ToCharArray();

#region IWordLibraryImport Members

Expand Down Expand Up @@ -171,7 +170,7 @@ private IList<WordLibrary> ReadAPinyinWord(FileStream fs)
if (key < pyDic.Count)
wordPY.Add(pyDic[key]);
else
wordPY.Add(a2zchar[key - pyDic.Count].ToString());
wordPY.Add(((char)(key - pyDic.Count + 97)).ToString());
//return null; // 用于调试,忽略编码异常的记录,不中止运行
}
//wordPY = wordPY.Remove(wordPY.Length - 1); //移除最后一个单引号
Expand Down
5 changes: 4 additions & 1 deletion src/ImeWlConverterCore/IME/SougouPinyinScel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,10 @@ private IList<WordLibrary> ReadAPinyinWord(FileStream fs)
for (int i = 0; i < count / 2; i++)
{
int key = str[i * 2] + str[i * 2 + 1] * 256;
wordPY.Add(pyDic[key]);
if (key < pyDic.Count)
wordPY.Add(pyDic[key]);
else
wordPY.Add(((char)(key - pyDic.Count + 97)).ToString());
}
//wordPY = wordPY.Remove(wordPY.Length - 1); //移除最后一个单引号
//接下来读词语
Expand Down

0 comments on commit 9ce6aae

Please sign in to comment.