ace/Source/ACE.Common/Extensions/CharacterNameExtensions.cs
Galli ecd6ce2b43
Remove UTF-8 BOMs across repository (#4324)
* remove bom from source files

* Remove stray BOM cleanup comments
2025-06-22 15:33:36 -04:00

31 lines
1.4 KiB
C#

namespace ACE.Common.Extensions
{
/// <summary>
/// This is a Helper Extension to service common String functions for Names
/// </summary>
public static class CharacterNameExtensions
{
/// <summary>
/// This is a Player Name Helper that converts a string array into a string with necessary spaces throughout. This is used by server commands.
/// </summary>
/// <param name="nameStrings">Array of strings, may contain spaces.</param>
/// <param name="startingElement">The starting position of the array where the character name begins. This is usually 1 when working with server commands.</param>
/// <returns>string containing a character or account name</returns>
public static string StringArrayToCharacterName(string[] nameStrings, int startingElement = 0)
{
// Store the first part of the player name.
string characterName = nameStrings[startingElement];
// Determine if the name has a space
if (nameStrings.Length > 2)
{
// Build the name
// characterName should already contain one element, so we start at the next position:
for (int i = (startingElement + 1); i < nameStrings.Length; i++)
{
characterName = characterName + " " + nameStrings[i];
}
}
return characterName;
}
}
}