Skip to content

Commit

Permalink
Ikkoku/clean: remove \uFE0F and single surrogate char
Browse files Browse the repository at this point in the history
  • Loading branch information
MIRIMIRIM committed Apr 21, 2024
1 parent 11ff6e8 commit a4b72c4
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 deletions Ikkoku/src/SubtileProcess/Clean.cs
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,11 @@ private static void RemoveWeridChars(List<char[]> et, ref bool hadUnusedChar, re
var _mod = false;
for (var j = 0; j < et.Count; j++)
{
var blk = et.ToArray()[j];
foreach (var c in blk)
var blk = et[j];

for (var k = 0; k < blk.Length; k++)
{
var c = blk[k];
if (Check.EventUnusedChars.Contains(c))
{
_mod = true;
Expand All @@ -273,6 +275,32 @@ private static void RemoveWeridChars(List<char[]> et, ref bool hadUnusedChar, re
hadWeridSpace = true;
}
}
else if (c == '\uFE0F')
{
// Now libass not support color emoji (https://github.com/libass/libass/issues/381), the char is meaningless
_mod = true;
if (!hadUnusedChar)
{
hadUnusedChar = true;
}
}
else if (char.IsHighSurrogate(c))
{
if (k + 1 < blk.Length && char.IsLowSurrogate(blk[k + 1]))
{
sb.Append(c);
sb.Append(blk[k + 1]);
k++;
}
else
{
_mod = true;
if (!hadUnusedChar)
{
hadUnusedChar = true;
}
}
}
else
{
sb.Append(c);
Expand Down

0 comments on commit a4b72c4

Please sign in to comment.