Updated code to correct build errors for Jellyfin.Extensions
This commit is contained in:
@@ -2,41 +2,26 @@
|
||||
// Copyright (c) PlaceholderCompany. All rights reserved.
|
||||
// </copyright>
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using ICU4N.Text;
|
||||
#pragma warning disable SA1309 // Variables should not begin with underscore
|
||||
#pragma warning disable SA1201 // A field should not follow a method
|
||||
#pragma warning disable SA1512 // Single line comment should be proceeded by blank line
|
||||
|
||||
namespace Jellyfin.Extensions
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using ICU4N.Text;
|
||||
|
||||
/// <summary>
|
||||
/// Provides extensions methods for <see cref="string" />.
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// Checks whether or not the specified string has diacritics in it.
|
||||
/// </summary>
|
||||
public static partial class StringExtensions
|
||||
{
|
||||
private static readonly Lazy<string> _transliteratorId = new(() =>
|
||||
Environment.GetEnvironmentVariable("JELLYFIN_TRANSLITERATOR_ID")
|
||||
?? "Any-Latin; Latin-Ascii; Lower; NFD; [:Nonspacing Mark:] Remove; [:Punctuation:] Remove;");
|
||||
|
||||
private static readonly Lazy<Transliterator?> _transliterator = new(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
return Transliterator.GetInstance(_transliteratorId.Value);
|
||||
}
|
||||
catch (ArgumentException)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
// Matches non-conforming unicode chars
|
||||
// https://mnaoumov.wordpress.com/2014/06/14/stripping-invalid-characters-from-utf-16-strings/
|
||||
|
||||
[GeneratedRegex("([\ud800-\udbff](?![\udc00-\udfff]))|((?<![\ud800-\udbff])[\udc00-\udfff])|(�)")]
|
||||
private static partial Regex NonConformingUnicodeRegex();
|
||||
|
||||
/// <summary>
|
||||
/// Removes the diacritics character from the strings.
|
||||
/// </summary>
|
||||
@@ -152,5 +137,27 @@ namespace Jellyfin.Extensions
|
||||
{
|
||||
return string.IsNullOrEmpty(text) ? text : text.AsSpan().LeftPart('\0').ToString();
|
||||
}
|
||||
|
||||
private static readonly Lazy<string> _transliteratorId = new(() =>
|
||||
Environment.GetEnvironmentVariable("JELLYFIN_TRANSLITERATOR_ID")
|
||||
?? "Any-Latin; Latin-Ascii; Lower; NFD; [:Nonspacing Mark:] Remove; [:Punctuation:] Remove;");
|
||||
|
||||
private static readonly Lazy<Transliterator?> _transliterator = new(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
return Transliterator.GetInstance(_transliteratorId.Value);
|
||||
}
|
||||
catch (ArgumentException)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
// Matches non-conforming unicode chars
|
||||
// https://mnaoumov.wordpress.com/2014/06/14/stripping-invalid-characters-from-utf-16-strings/
|
||||
|
||||
[GeneratedRegex("([\ud800-\udbff](?![\udc00-\udfff]))|((?<![\ud800-\udbff])[\udc00-\udfff])|(�)")]
|
||||
private static partial Regex NonConformingUnicodeRegex();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user