Iceshrimp.NET/Iceshrimp.Backend/Core/Extensions/StringExtensions.cs
2024-01-26 18:57:59 +01:00

17 lines
No EOL
451 B
C#

using System.Globalization;
namespace Iceshrimp.Backend.Core.Extensions;
public static class StringExtensions {
public static string Truncate(this string target, int maxLength) {
return target[..Math.Min(target.Length, maxLength)];
}
public static string ToPunycode(this string target) {
return new IdnMapping().GetAscii(target);
}
public static string FromPunycode(this string target) {
return new IdnMapping().GetUnicode(target);
}
}