1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-18 08:32:54 +08:00

Constrain range of usable characters in romanised metadata to ASCII only

Closes https://github.com/ppy/osu/issues/31398.

Rationale given in issue.

Compare stable logic:

- 2280c4c436/osu!/GameModes/Edit/Forms/SongSetup.cs#L118-L122
- 2280c4c436/osu!common/Helpers/GeneralHelper.cs#L410-L423

The control character check is a bit gratuitous (text boxes will already
not allow insertion of those, see
e05cb86ff6/osu.Framework/Graphics/UserInterface/TextBox.cs (L92)),
but as it's a general helper I figured might as well.
This commit is contained in:
Bartłomiej Dach 2025-01-06 14:04:47 +01:00
parent 448790a76f
commit 3a4497af32
No known key found for this signature in database

View File

@ -15,7 +15,7 @@ namespace osu.Game.Beatmaps
/// Returns <see langword="true"/> if the character <paramref name="c"/> can be used in <see cref="BeatmapMetadata.Artist"/> and <see cref="BeatmapMetadata.Title"/> fields.
/// Characters not matched by this method can be placed in <see cref="BeatmapMetadata.ArtistUnicode"/> and <see cref="BeatmapMetadata.TitleUnicode"/>.
/// </summary>
public static bool IsRomanised(char c) => c <= 0xFF;
public static bool IsRomanised(char c) => char.IsAscii(c) && !char.IsControl(c);
/// <summary>
/// Returns <see langword="true"/> if the string <paramref name="str"/> can be used in <see cref="BeatmapMetadata.Artist"/> and <see cref="BeatmapMetadata.Title"/> fields.