diff options
Diffstat (limited to 'MediaBrowser.Common/Extensions/BaseExtensions.cs')
| -rw-r--r-- | MediaBrowser.Common/Extensions/BaseExtensions.cs | 43 |
1 files changed, 13 insertions, 30 deletions
diff --git a/MediaBrowser.Common/Extensions/BaseExtensions.cs b/MediaBrowser.Common/Extensions/BaseExtensions.cs index 452c47159..4c94f3aa2 100644 --- a/MediaBrowser.Common/Extensions/BaseExtensions.cs +++ b/MediaBrowser.Common/Extensions/BaseExtensions.cs @@ -1,4 +1,6 @@ using System; +using System.Globalization; +using System.Linq; using System.Security.Cryptography; using System.Text; using System.Text.RegularExpressions; @@ -54,6 +56,15 @@ namespace MediaBrowser.Common.Extensions return sb.ToString(); } + public static string RemoveDiacritics(this string text) + { + return String.Concat( + text.Normalize(NormalizationForm.FormD) + .Where(ch => CharUnicodeInfo.GetUnicodeCategory(ch) != + UnicodeCategory.NonSpacingMark) + ).Normalize(NormalizationForm.FormC); + } + /// <summary> /// Gets the M d5. /// </summary> @@ -73,6 +84,8 @@ namespace MediaBrowser.Common.Extensions /// <param name="str">The STR.</param> /// <param name="type">The type.</param> /// <returns>Guid.</returns> + /// <exception cref="System.ArgumentNullException">type</exception> + [Obsolete("Use LibraryManager.GetNewItemId")] public static Guid GetMBId(this string str, Type type) { if (type == null) @@ -84,35 +97,5 @@ namespace MediaBrowser.Common.Extensions return key.GetMD5(); } - - /// <summary> - /// Gets the attribute value. - /// </summary> - /// <param name="str">The STR.</param> - /// <param name="attrib">The attrib.</param> - /// <returns>System.String.</returns> - /// <exception cref="System.ArgumentNullException">attrib</exception> - public static string GetAttributeValue(this string str, string attrib) - { - if (string.IsNullOrEmpty(str)) - { - throw new ArgumentNullException("str"); - } - - if (string.IsNullOrEmpty(attrib)) - { - throw new ArgumentNullException("attrib"); - } - - string srch = "[" + attrib + "="; - int start = str.IndexOf(srch, StringComparison.OrdinalIgnoreCase); - if (start > -1) - { - start += srch.Length; - int end = str.IndexOf(']', start); - return str.Substring(start, end - start); - } - return null; - } } } |
