This repository has been archived by the owner on May 27, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ID32TranslitTools.cs
58 lines (52 loc) · 1.55 KB
/
ID32TranslitTools.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace ID32Translit
{
class ID32TranslitTools
{
public static string ConvertToUtf8(string s)
{
if (s != null)
{
return new string(s.ToCharArray().
Select(x => ((x + 848) >= 'А' && (x + 848) <= 'ё') ? (char)(x + 848) : x).
ToArray());
}
return "";
}
public static Boolean isCyrillic(String s)
{
if (s != null)
{
return Regex.IsMatch(s, @"\p{IsCyrillic}");
}
return false;
}
public static Boolean IsEnglish(string inputstring)
{
if (inputstring != null)
{
Regex regex = new Regex(@"[¸`A-Za-z0-9\s\.,-=+\(){}\[\]?|_»«@#$%^&*\t!""'/]");
MatchCollection matches = regex.Matches(inputstring);
if (matches.Count == inputstring.Length)
{
return true;
}
return false;
}
return true;
}
public static Boolean checkIfID3AreInEnglish(ref TagLib.File ID3)
{
if (!IsEnglish(ID3.Tag.Title) || !IsEnglish(ID3.Tag.FirstPerformer) || !IsEnglish(ID3.Tag.Album))
{
return false;
}
return true;
}
}
}