2024-09-29 01:15:33 +03:00
|
|
|
namespace Content.Server.GuideGenerator.TextTools;
|
|
|
|
|
|
|
|
|
|
public sealed class TextTools
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Capitalizes first letter of given string.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="str">String to capitalize</param>
|
|
|
|
|
/// <returns>String with capitalized first letter</returns>
|
|
|
|
|
public static string CapitalizeString(string str)
|
|
|
|
|
{
|
|
|
|
|
if (str.Length > 1)
|
|
|
|
|
{
|
2025-01-28 20:40:56 +03:00
|
|
|
return OopsConcat(char.ToUpper(str[0]).ToString(), str.Remove(0, 1));
|
2024-09-29 01:15:33 +03:00
|
|
|
}
|
|
|
|
|
else if (str.Length == 1)
|
|
|
|
|
{
|
|
|
|
|
return char.ToUpper(str[0]).ToString();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return str;
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-01-28 20:40:56 +03:00
|
|
|
|
|
|
|
|
private static string OopsConcat(string a, string b)
|
|
|
|
|
{
|
|
|
|
|
// This exists to prevent Roslyn being clever and compiling something that fails sandbox checks.
|
|
|
|
|
return a + b;
|
|
|
|
|
}
|
2024-09-29 01:15:33 +03:00
|
|
|
}
|