Up to date
This page is up to date for Godot 4.1
.
If you still find outdated information, please open an issue.
StringName¶
A built-in type for unique strings.
Description¶
StringNames are immutable strings designed for general-purpose representation of unique names (also called "string interning"). Two StringNames with the same value are the same object. Comparing them is extremely fast compared to regular Strings.
You will usually just pass a String to methods expecting a StringName and it will be automatically converted, but you may occasionally want to construct a StringName ahead of time with the StringName constructor or, in GDScript, the literal syntax &"example"
.
See also NodePath, which is a similar concept specifically designed to store pre-parsed scene tree paths.
All of String's methods are available in this class too. They convert the StringName into a string, and they also return a string. This is highly inefficient and should only be used if the string is desired.
Note: In C#, an explicit conversion to System.String
is required to use the methods listed on this page. Use the ToString()
method to cast a StringName to a string, and then use the equivalent methods in System.String
or StringExtensions
.
Note: In a boolean context, a StringName will evaluate to false
if it is empty (StringName("")
). Otherwise, a StringName will always evaluate to true
. The not
operator cannot be used. Instead, is_empty should be used to check for empty StringNames.
Constructors¶
StringName ( ) |
|
StringName ( StringName from ) |
|
StringName ( String from ) |
Methods¶
begins_with ( String text ) const |
|
bigrams ( ) const |
|
bin_to_int ( ) const |
|
c_escape ( ) const |
|
c_unescape ( ) const |
|
capitalize ( ) const |
|
casecmp_to ( String to ) const |
|
dedent ( ) const |
|
get_base_dir ( ) const |
|
get_basename ( ) const |
|
get_extension ( ) const |
|
get_file ( ) const |
|
get_slice_count ( String delimiter ) const |
|
get_slicec ( int delimiter, int slice ) const |
|
hash ( ) const |
|
hex_decode ( ) const |
|
hex_to_int ( ) const |
|
is_absolute_path ( ) const |
|
is_empty ( ) const |
|
is_relative_path ( ) const |
|
is_subsequence_of ( String text ) const |
|
is_subsequence_ofn ( String text ) const |
|
is_valid_filename ( ) const |
|
is_valid_float ( ) const |
|
is_valid_hex_number ( bool with_prefix=false ) const |
|
is_valid_html_color ( ) const |
|
is_valid_identifier ( ) const |
|
is_valid_int ( ) const |
|
is_valid_ip_address ( ) const |
|
join ( PackedStringArray parts ) const |
|
json_escape ( ) const |
|
length ( ) const |
|
md5_buffer ( ) const |
|
md5_text ( ) const |
|
naturalcasecmp_to ( String to ) const |
|
naturalnocasecmp_to ( String to ) const |
|
nocasecmp_to ( String to ) const |
|
pad_decimals ( int digits ) const |
|
rsplit ( String delimiter="", bool allow_empty=true, int maxsplit=0 ) const |
|
sha1_buffer ( ) const |
|
sha1_text ( ) const |
|
sha256_buffer ( ) const |
|
sha256_text ( ) const |
|
similarity ( String text ) const |
|
simplify_path ( ) const |
|
split ( String delimiter="", bool allow_empty=true, int maxsplit=0 ) const |
|
split_floats ( String delimiter, bool allow_empty=true ) const |
|
strip_edges ( bool left=true, bool right=true ) const |
|
strip_escapes ( ) const |
|
to_ascii_buffer ( ) const |
|
to_camel_case ( ) const |
|
to_float ( ) const |
|
to_int ( ) const |
|
to_lower ( ) const |
|
to_pascal_case ( ) const |
|
to_snake_case ( ) const |
|
to_upper ( ) const |
|
to_utf8_buffer ( ) const |
|
to_utf16_buffer ( ) const |
|
to_utf32_buffer ( ) const |
|
to_wchar_buffer ( ) const |
|
trim_prefix ( String prefix ) const |
|
trim_suffix ( String suffix ) const |
|
unicode_at ( int at ) const |
|
uri_decode ( ) const |
|
uri_encode ( ) const |
|
validate_filename ( ) const |
|
validate_node_name ( ) const |
|
xml_escape ( bool escape_quotes=false ) const |
|
xml_unescape ( ) const |
Operators¶
operator != ( String right ) |
|
operator != ( StringName right ) |
|
operator % ( Variant right ) |
|
operator + ( String right ) |
|
operator + ( StringName right ) |
|
operator < ( StringName right ) |
|
operator <= ( StringName right ) |
|
operator == ( String right ) |
|
operator == ( StringName right ) |
|
operator > ( StringName right ) |
|
operator >= ( StringName right ) |