mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-26 05:02: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,17 +61,10 @@ namespace Nikse.SubtitleEdit.Core.Common.TextLengthCalculator
|
||||
ch != '\u202D' &&
|
||||
ch != '\u202E')
|
||||
{
|
||||
if (IsChinese(ch))
|
||||
{
|
||||
if (JapaneseHalfWidthCharacters.Contains(ch))
|
||||
{
|
||||
count += 0.5m;
|
||||
}
|
||||
else
|
||||
if (IsCjk(ch))
|
||||
{
|
||||
count++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
count += 0.5m;
|
||||
@ -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,17 +60,10 @@
|
||||
ch != '\u202D' &&
|
||||
ch != '\u202E')
|
||||
{
|
||||
if (CalcCjk.IsChinese(ch))
|
||||
{
|
||||
if (CalcCjk.JapaneseHalfWidthCharacters.Contains(ch))
|
||||
{
|
||||
count += 0.5m;
|
||||
}
|
||||
else
|
||||
if (CalcCjk.IsCjk(ch))
|
||||
{
|
||||
count++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
count += 0.5m;
|
||||
|
Loading…
Reference in New Issue
Block a user