mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-22 11:12:36 +01:00
Minor fix for CJK line length - thx Leon :)
Related to #5711 + https://github.com/SubtitleEdit/subtitleedit/discussions/5711#discussioncomment-2040649
This commit is contained in:
parent
a65c42e346
commit
3831416791
@ -46,6 +46,10 @@ namespace Nikse.SubtitleEdit.Core.Common.TextLengthCalculator
|
||||
{
|
||||
htmlTagOn = true;
|
||||
}
|
||||
else if (JapaneseHalfWidthCharacters.Contains(ch))
|
||||
{
|
||||
count += 0.5m;
|
||||
}
|
||||
else if (!char.IsControl(ch) &&
|
||||
ch != zeroWidthSpace &&
|
||||
ch != zeroWidthNoBreakSpace &&
|
||||
@ -57,16 +61,9 @@ namespace Nikse.SubtitleEdit.Core.Common.TextLengthCalculator
|
||||
ch != '\u202D' &&
|
||||
ch != '\u202E')
|
||||
{
|
||||
if (IsChinese(ch))
|
||||
if (IsCjk(ch))
|
||||
{
|
||||
if (JapaneseHalfWidthCharacters.Contains(ch))
|
||||
{
|
||||
count += 0.5m;
|
||||
}
|
||||
else
|
||||
{
|
||||
count++;
|
||||
}
|
||||
count++;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -82,8 +79,13 @@ namespace Nikse.SubtitleEdit.Core.Common.TextLengthCalculator
|
||||
public const string JapaneseHalfWidthCharacters = "。「」、・ヲァィゥェォャュョッーアイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン゙゚";
|
||||
|
||||
public static readonly Regex CjkCharRegex = new Regex(@"\p{IsCJKUnifiedIdeographs}", RegexOptions.Compiled);
|
||||
public static bool IsChinese(char c)
|
||||
public static bool IsCjk(char c)
|
||||
{
|
||||
if (c == '。' || c == ',')
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return CjkCharRegex.IsMatch(c.ToString());
|
||||
}
|
||||
}
|
||||
|
@ -44,6 +44,10 @@
|
||||
{
|
||||
htmlTagOn = true;
|
||||
}
|
||||
else if (CalcCjk.JapaneseHalfWidthCharacters.Contains(ch))
|
||||
{
|
||||
count += 0.5m;
|
||||
}
|
||||
else if (!char.IsControl(ch) &&
|
||||
ch != ' ' &&
|
||||
ch != zeroWidthSpace &&
|
||||
@ -56,16 +60,9 @@
|
||||
ch != '\u202D' &&
|
||||
ch != '\u202E')
|
||||
{
|
||||
if (CalcCjk.IsChinese(ch))
|
||||
if (CalcCjk.IsCjk(ch))
|
||||
{
|
||||
if (CalcCjk.JapaneseHalfWidthCharacters.Contains(ch))
|
||||
{
|
||||
count += 0.5m;
|
||||
}
|
||||
else
|
||||
{
|
||||
count++;
|
||||
}
|
||||
count++;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -73,7 +70,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user