Class StringUtil
- Namespace
- Vintagestory.API.Util
- Assembly
- VintagestoryAPI.dll
public static class StringUtil
- Inheritance
-
StringUtil
- Inherited Members
Methods
CompareOrdinal(string, string)
This should be used for every string comparison when ordering strings (except possibly in localised output to the user) in order to avoid any
culture specific string comparison issues in certain languages (worst in the Thai language which has no spaces and treats punctuation marks as invisible)
See also: https://learn.microsoft.com/en-us/dotnet/standard/base-types/best-practices-strings
public static int CompareOrdinal(this string a, string b)
Parameters
Returns
ContainsFast(string, char)
public static bool ContainsFast(this string value, char reference)
Parameters
Returns
ContainsFast(string, string)
public static bool ContainsFast(this string value, string reference)
Parameters
Returns
CountChars(string, char)
public static int CountChars(this string text, char c)
Parameters
Returns
EndsWithOrdinal(string, string)
IMPORTANT! This method should be used for every EndsWith operation in our code (except possibly in localised output to the user). This is important in order to avoid any
culture-specific different results even when examining strings in English, when the user machine's current culture is a different language
(Known issue in the Thai language which has no spaces and treats punctuation marks as invisible, see https://github.com/dotnet/runtime/issues/59120)
See also: https://learn.microsoft.com/en-us/dotnet/standard/base-types/best-practices-strings
public static bool EndsWithOrdinal(this string a, string b)
Parameters
Returns
EqualsFast(string, string)
public static bool EqualsFast(this string value, string reference)
Parameters
Returns
FastStartsWith(string, string, int)
public static bool FastStartsWith(string value, string reference, int len)
Parameters
Returns
GetNonRandomizedHashCode(string)
public static int GetNonRandomizedHashCode(this string str)
Parameters
str
string
Returns
IndexOfOrdinal(string, string)
IMPORTANT! This method should be used for every IndexOf operation in our code (except possibly in localised output to the user). This is important in order to avoid any
culture-specific different results even when indexing GLSL shader code or other code strings, etc., or other strings in English, when the current culture is a different language
(Known issue in the Thai language which has no spaces and treats punctuation marks as invisible, see https://github.com/dotnet/runtime/issues/59120)
See also: https://learn.microsoft.com/en-us/dotnet/standard/base-types/best-practices-strings
public static int IndexOfOrdinal(this string a, string b)
Parameters
Returns
RemoveFileEnding(string)
public static string RemoveFileEnding(this string text)
Parameters
text
string
Returns
StartsWithFast(string, string)
public static bool StartsWithFast(this string value, string reference)
Parameters
Returns
StartsWithFast(string, string, int)
public static bool StartsWithFast(this string value, string reference, int offset)
Parameters
Returns
StartsWithOrdinal(string, string)
IMPORTANT! This method should be used for every StartsWith operation in our code (except possibly in localised output to the user). This is important in order to avoid any
culture-specific different results even when examining strings in English, when the user machine's current culture is a different language
(Known issue in the Thai language which has no spaces and treats punctuation marks as invisible, see https://github.com/dotnet/runtime/issues/59120)
See also: https://learn.microsoft.com/en-us/dotnet/standard/base-types/best-practices-strings
public static bool StartsWithOrdinal(this string a, string b)
Parameters
Returns
ToBool(string, bool)
public static bool ToBool(this string text, bool defaultValue = false)
Parameters
Returns
ToDouble(string, double)
public static double ToDouble(this string text, double defaultValue = 0)
Parameters
Returns
ToDoubleOrNull(string, double?)
public static double? ToDoubleOrNull(this string text, double? defaultValue = 0)
Parameters
Returns
ToFloat(string, float)
public static float ToFloat(this string text, float defaultValue = 0)
Parameters
Returns
ToFloatOrNull(string, float?)
public static float? ToFloatOrNull(this string text, float? defaultValue = 0)
Parameters
Returns
ToInt(string, int)
public static int ToInt(this string text, int defaultValue = 0)
Parameters
Returns
ToLong(string, long)
public static long ToLong(this string text, long defaultValue = 0)
Parameters
Returns
ToSearchFriendly(string)
Removes diacritics and replaces quotation marks, guillemets and brackets with a blank space. Used to create a search friendly term
public static string ToSearchFriendly(this string stIn)
Parameters
stIn
string
Returns
UcFirst(string)
Convert the first character to an uppercase one
public static string UcFirst(this string text)
Parameters
text
string