mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-25 04:33:04 +01:00
Fix #7275
This commit is contained in:
parent
32524d27de
commit
4fe20da148
@ -1886,16 +1886,13 @@ namespace Nikse.SubtitleEdit.Core.Common
|
||||
return false;
|
||||
}
|
||||
|
||||
public static string KoreanLetters = "가나다라마바사아자차카타파하아야어여오요우유으이대한민국활화산동물들천국의섬유독춤을춥니다";
|
||||
public static string JapaneseLetters = "あいうえおかきくけこがぎぐげごさしすせそざじずぜぞたちつてとだぢづでどなにぬねのはひふへほばびぶべぼぱぴぷぺぽまみむめもやゆよらりるれろわをん";
|
||||
|
||||
public static string GetEncodingViaLetter(string text)
|
||||
{
|
||||
var dictionary = new Dictionary<string, int>();
|
||||
var dictionary = new Dictionary<string, int>(6);
|
||||
|
||||
// Arabic
|
||||
int count = 0;
|
||||
foreach (var letter in "غظضذخثتشرقصفعسنملكيطحزوهدجبا")
|
||||
var count = 0;
|
||||
foreach (var letter in Alphabets.Arabic)
|
||||
{
|
||||
if (text.Contains(letter))
|
||||
{
|
||||
@ -1906,7 +1903,7 @@ namespace Nikse.SubtitleEdit.Core.Common
|
||||
|
||||
// Korean
|
||||
count = 0;
|
||||
foreach (var letter in KoreanLetters)
|
||||
foreach (var letter in Alphabets.Korean)
|
||||
{
|
||||
if (text.Contains(letter))
|
||||
{
|
||||
@ -1917,7 +1914,7 @@ namespace Nikse.SubtitleEdit.Core.Common
|
||||
|
||||
// Japanese
|
||||
count = 0;
|
||||
foreach (var letter in JapaneseLetters)
|
||||
foreach (var letter in Alphabets.Japanese)
|
||||
{
|
||||
if (text.Contains(letter))
|
||||
{
|
||||
@ -1928,7 +1925,7 @@ namespace Nikse.SubtitleEdit.Core.Common
|
||||
|
||||
// Thai
|
||||
count = 0;
|
||||
foreach (var letter in "กขฃคฅฆงจฉชซฌญฎฏฐฑฒณดตถทธนบปผฝพฟภมยรลวศษสหฬอฮ")
|
||||
foreach (var letter in Alphabets.Thai)
|
||||
{
|
||||
if (text.Contains(letter))
|
||||
{
|
||||
@ -1939,7 +1936,7 @@ namespace Nikse.SubtitleEdit.Core.Common
|
||||
|
||||
// Sinhalese
|
||||
count = 0;
|
||||
foreach (var letter in "අආඇඈඉඊඋඌඍඎඏඐඑඒඓඔඕඖකඛගඝඞඟචඡජඣඤඥඦටඨඩඪණඬතථදධනඳපඵබභමඹයරලවශෂසහළෆ්ාැෑිීුූෘෙේෛොෝෞෟ෦෧෨෩෪෫෬෭෮෯")
|
||||
foreach (var letter in Alphabets.Sinhalese)
|
||||
{
|
||||
if (text.Contains(letter))
|
||||
{
|
||||
@ -1950,7 +1947,7 @@ namespace Nikse.SubtitleEdit.Core.Common
|
||||
|
||||
// Urdu
|
||||
count = 0;
|
||||
foreach (var letter in "ﺍﺎﺁﺂﺏﺑﺒﺐﭖﭘﭙﭗﺕﺗﺘﺖﭦﭨﭩﭧﺙﺛﺜﺚﺝﺟﺠﺞﭺﭼﭽﭻﺡﺣﺤﺢﺥﺧﺨﺦﺩﺪﺫﺬﺭﺮﮌﮍﺯﺰﮊﮋﺱﺳﺴﺲﺵﺷﺸﺶﺹﺻﺼﺺﺽﺿﻀﺾﻁﻃﻄﻂﻅﻇﻈﻆﻉﻋﻌﻊﻍﻏﻐﻎﻑﻓﻔﻒﻕﻗﻘﻖﻙﻛﻜﻚﻻﻼﻝﻟﻠﻞﻡﻣﻤﻢﻥﻧﻨﻦﻭﻮﮮﮯﮦﮨﮩﮧﯼﯾﯿﯽﮪﮬﮭﮫﴽﴼﺀﺋﺌﹱﹷﹹ")
|
||||
foreach (var letter in Alphabets.Urdu)
|
||||
{
|
||||
if (text.Contains(letter))
|
||||
{
|
||||
@ -1967,5 +1964,15 @@ namespace Nikse.SubtitleEdit.Core.Common
|
||||
{
|
||||
return language == "ko" || language == "zh" || language == "ja" || language == "th";
|
||||
}
|
||||
|
||||
public static class Alphabets
|
||||
{
|
||||
public const string Arabic = "غظضذخثتشرقصفعسنملكيطحزوهدجبا";
|
||||
public const string Korean = "가나다라마바사아자차카타파하아야어여오요우유으이대한민국활화산동물들천국의섬유독춤을춥니다";
|
||||
public const string Japanese = "あいうえおかきくけこがぎぐげごさしすせそざじずぜぞたちつてとだぢづでどなにぬねのはひふへほばびぶべぼぱぴぷぺぽまみむめもやゆよらりるれろわをん";
|
||||
public const string Thai = "กขฃคฅฆงจฉชซฌญฎฏฐฑฒณดตถทธนบปผฝพฟภมยรลวศษสหฬอฮ";
|
||||
public const string Urdu = "ﺍﺎﺁﺂﺏﺑﺒﺐﭖﭘﭙﭗﺕﺗﺘﺖﭦﭨﭩﭧﺙﺛﺜﺚﺝﺟﺠﺞﭺﭼﭽﭻﺡﺣﺤﺢﺥﺧﺨﺦﺩﺪﺫﺬﺭﺮﮌﮍﺯﺰﮊﮋﺱﺳﺴﺲﺵﺷﺸﺶﺹﺻﺼﺺﺽﺿﻀﺾﻁﻃﻄﻂﻅﻇﻈﻆﻉﻋﻌﻊﻍﻏﻐﻎﻑﻓﻔﻒﻕﻗﻘﻖﻙﻛﻜﻚﻻﻼﻝﻟﻠﻞﻡﻣﻤﻢﻥﻧﻨﻦﻭﻮﮮﮯﮦﮨﮩﮧﯼﯾﯿﯽﮪﮬﮭﮫﴽﴼﺀﺋﺌﹱﹷﹹ";
|
||||
public const string Sinhalese = "අආඇඈඉඊඋඌඍඎඏඐඑඒඓඔඕඖකඛගඝඞඟචඡජඣඤඥඦටඨඩඪණඬතථදධනඳපඵබභමඹයරලවශෂසහළෆ්ාැෑිීුූෘෙේෛොෝෞෟ෦෧෨෩෪෫෬෭෮෯";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -62,8 +62,8 @@ namespace Nikse.SubtitleEdit.Core.Common.TextLengthCalculator
|
||||
count += 0.5m;
|
||||
}
|
||||
else if (ChineseFullWidthPunctuations.Contains(ch) ||
|
||||
LanguageAutoDetect.JapaneseLetters.Contains(ch) ||
|
||||
LanguageAutoDetect.KoreanLetters.Contains(ch) ||
|
||||
LanguageAutoDetect.Alphabets.Japanese.Contains(ch) ||
|
||||
LanguageAutoDetect.Alphabets.Korean.Contains(ch) ||
|
||||
IsCjk(ch))
|
||||
{
|
||||
count++;
|
||||
|
@ -61,8 +61,8 @@
|
||||
count += 0.5m;
|
||||
}
|
||||
else if (CalcCjk.ChineseFullWidthPunctuations.Contains(ch) ||
|
||||
LanguageAutoDetect.JapaneseLetters.Contains(ch) ||
|
||||
LanguageAutoDetect.KoreanLetters.Contains(ch) ||
|
||||
LanguageAutoDetect.Alphabets.Japanese.Contains(ch) ||
|
||||
LanguageAutoDetect.Alphabets.Korean.Contains(ch) ||
|
||||
CalcCjk.IsCjk(ch))
|
||||
{
|
||||
count++;
|
||||
|
Loading…
Reference in New Issue
Block a user