// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using System.Linq; using System.Text; namespace osu.Game.Beatmaps { /// /// Groups utility methods used to handle beatmap metadata. /// public static class MetadataUtils { /// /// Returns if the character can be used in and fields. /// Characters not matched by this method can be placed in and . /// public static bool IsRomanised(char c) => c <= 0xFF; /// /// Returns if the string can be used in and fields. /// Strings not matched by this method can be placed in and . /// public static bool IsRomanised(string? str) => string.IsNullOrEmpty(str) || str.All(IsRomanised); /// /// Returns a copy of with all characters that do not match removed. /// public static string StripNonRomanisedCharacters(string? str) { if (string.IsNullOrEmpty(str)) return string.Empty; var stringBuilder = new StringBuilder(str.Length); foreach (char c in str) { if (IsRomanised(c)) stringBuilder.Append(c); } return stringBuilder.ToString().Trim(); } } }