Skip to main content

Class StringExtensions

Extension methods for strings.

Assembly: Dalamud.dll
View Source
Declaration
public static class StringExtensions

Methods

Format(string, params object[])

An extension method to chain usage of string.Format.

View Source
Declaration
public static string Format(this string format, params object[] args)
Returns

System.String: Formatted string.

Parameters
TypeNameDescription
System.StringformatFormat string.
System.Object[]argsFormat arguments.

IsNullOrEmpty(string?)

Indicates whether the specified string is null or an empty string ("").

View Source
Declaration
public static bool IsNullOrEmpty(this string? value)
Returns

System.Boolean: true if the value parameter is null or an empty string (""); otherwise, false.

Parameters
TypeNameDescription
System.StringvalueThe string to test.

IsNullOrWhitespace(string?)

Indicates whether a specified string is null, empty, or consists only of white-space characters.

View Source
Declaration
public static bool IsNullOrWhitespace(this string? value)
Returns

System.Boolean: true if the value parameter is null or an empty string (""), or if value consists exclusively of white-space characters.

Parameters
TypeNameDescription
System.StringvalueThe string to test.

IsValidCharacterName(string, bool)

Validate if character name is valid using game check.

View Source
Declaration
public static bool IsValidCharacterName(this string value, bool includeLegacy = true)
Returns

System.Boolean: indicator if character is name is valid.

Parameters
TypeNameDescription
System.Stringvaluecharacter name to validate.
System.BooleanincludeLegacyinclude legacy names (combined can be 30 instead of 20).

FirstCharToUpper(string?, CultureInfo?)

Converts the first character of the string to uppercase while leaving the rest of the string unchanged.

View Source
Declaration
public static string? FirstCharToUpper(this string? input, CultureInfo? culture = null)
Returns

System.String: A new string with the first character converted to uppercase.

Parameters
TypeNameDescription
System.StringinputThe input string.
System.Globalization.CultureInfoculture

FirstCharToLower(string?, CultureInfo?)

Converts the first character of the string to lowercase while leaving the rest of the string unchanged.

View Source
Declaration
public static string? FirstCharToLower(this string? input, CultureInfo? culture = null)
Returns

System.String: A new string with the first character converted to lowercase.

Parameters
TypeNameDescription
System.StringinputThe input string.
System.Globalization.CultureInfoculture

StripSoftHyphen(string)

Removes soft hyphen characters (U+00AD) from the input string.

View Source
Declaration
public static string StripSoftHyphen(this string input)
Returns

System.String: A string with all soft hyphens removed.

Parameters
TypeNameDescription
System.StringinputThe input string to remove soft hyphen characters from.

Truncate(string, int, string)

Truncates the given string to the specified maximum number of characters,
appending an ellipsis if truncation occurs.

View Source
Declaration
public static string? Truncate(this string input, int maxChars, string ellipses = "...")
Returns

System.String: The truncated string, or the original string if no truncation is needed.

Parameters
TypeNameDescription
System.StringinputThe string to truncate.
System.Int32maxCharsThe maximum allowed length of the string.
System.StringellipsesThe string to append if truncation occurs (defaults to "...").