-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
2. Rename 3. Update cache rule 4. Add "TraditionalToSimplified" function 5. Update UX
- Loading branch information
Showing
26 changed files
with
273 additions
and
185 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Reflection; | ||
using System.Text; | ||
|
||
namespace NLyric { | ||
internal static class ChineseConverter { | ||
private static readonly Dictionary<char, char> _traditionalToSimplifiedMap; | ||
|
||
static ChineseConverter() { | ||
Assembly assembly; | ||
|
||
assembly = Assembly.GetExecutingAssembly(); | ||
using (Stream stream = assembly.GetManifestResourceStream("NLyric.TraditionalToSimplified.map")) | ||
using (BinaryReader reader = new BinaryReader(stream)) { | ||
int count; | ||
|
||
count = (int)stream.Length / 4; | ||
_traditionalToSimplifiedMap = new Dictionary<char, char>(count); | ||
for (int i = 0; i < count; i++) | ||
_traditionalToSimplifiedMap.Add((char)reader.ReadUInt16(), (char)reader.ReadUInt16()); | ||
} | ||
} | ||
|
||
public static string TraditionalToSimplified(string s) { | ||
if (s is null) | ||
return null; | ||
|
||
StringBuilder sb; | ||
|
||
sb = new StringBuilder(s); | ||
for (int i = 0; i < sb.Length; i++) | ||
if (_traditionalToSimplifiedMap.TryGetValue(sb[i], out char c)) | ||
sb[i] = c; | ||
return sb.ToString(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.