diff options
Diffstat (limited to 'doc/classes/String.xml')
-rw-r--r-- | doc/classes/String.xml | 86 |
1 files changed, 62 insertions, 24 deletions
diff --git a/doc/classes/String.xml b/doc/classes/String.xml index a5a8766ca0..e513a44b1d 100644 --- a/doc/classes/String.xml +++ b/doc/classes/String.xml @@ -260,7 +260,7 @@ <return type="String"> </return> <description> - Changes the case of some letters. Replaces underscores with spaces, converts all letters to lowercase, then capitalizes first and every letter following the space character. For [code]capitalize camelCase mixed_with_underscores[/code] it will return [code]Capitalize Camelcase Mixed With Underscores[/code]. + Changes the case of some letters. Replaces underscores with spaces, converts all letters to lowercase, then capitalizes first and every letter following the space character. For [code]capitalize camelCase mixed_with_underscores[/code], it will return [code]Capitalize Camelcase Mixed With Underscores[/code]. </description> </method> <method name="casecmp_to"> @@ -276,7 +276,7 @@ <return type="String"> </return> <description> - Removes indentation from string. + Returns a copy of the string with indentation (leading tabs and spaces) removed. </description> </method> <method name="empty"> @@ -385,7 +385,30 @@ <return type="int"> </return> <description> - Converts a string containing a hexadecimal number into an integer. + Converts a string containing a hexadecimal number into an integer. Hexadecimal strings are expected to be prefixed with "[code]0x[/code]" otherwise [code]0[/code] is returned. + [codeblock] + print("0xff".hex_to_int()) # Print "255" + [/codeblock] + </description> + </method> + <method name="http_escape"> + <return type="String"> + </return> + <description> + Escapes (encodes) a string to URL friendly format. Also referred to as 'URL encode'. + [codeblock] + print("https://example.org/?escaped=" + "Godot Engine:'docs'".http_escape()) + [/codeblock] + </description> + </method> + <method name="http_unescape"> + <return type="String"> + </return> + <description> + Unescapes (decodes) a string in URL encoded format. Also referred to as 'URL decode'. + [codeblock] + print("https://example.org/?escaped=" + "Godot%20Engine%3A%27docs%27".http_unescape()) + [/codeblock] </description> </method> <method name="insert"> @@ -459,7 +482,7 @@ <return type="bool"> </return> <description> - Returns [code]true[/code] if this string contains a valid color in HTML notation. + Returns [code]true[/code] if this string contains a valid color in hexadecimal HTML notation. Other HTML notations such as named colors or [code]hsl()[/code] colors aren't considered valid by this method and will return [code]false[/code]. </description> </method> <method name="is_valid_identifier"> @@ -521,7 +544,7 @@ <argument index="0" name="expr" type="String"> </argument> <description> - Does a simple expression match, where [code]*[/code] matches zero or more arbitrary characters and [code]?[/code] matches any single character except '.'. + Does a simple case-sensitive expression match, where [code]"*"[/code] matches zero or more arbitrary characters and [code]"?"[/code] matches any single character except a period ([code]"."[/code]). </description> </method> <method name="matchn"> @@ -530,7 +553,7 @@ <argument index="0" name="expr" type="String"> </argument> <description> - Does a simple case insensitive expression match, using [code]?[/code] and [code]*[/code] wildcards (see [method match]). + Does a simple case-insensitive expression match, where [code]"*"[/code] matches zero or more arbitrary characters and [code]"?"[/code] matches any single character except a period ([code]"."[/code]). </description> </method> <method name="md5_buffer"> @@ -614,7 +637,7 @@ <argument index="1" name="forwhat" type="String"> </argument> <description> - Replaces occurrences of a substring with the given one inside the string. + Replaces occurrences of a case-sensitive substring with the given one inside the string. </description> </method> <method name="replacen"> @@ -625,7 +648,7 @@ <argument index="1" name="forwhat" type="String"> </argument> <description> - Replaces occurrences of a substring with the given one inside the string. Ignores case. + Replaces occurrences of a case-insensitive substring with the given one inside the string. </description> </method> <method name="rfind"> @@ -636,7 +659,7 @@ <argument index="1" name="from" type="int" default="-1"> </argument> <description> - Performs a search for a substring, but starts from the end of the string instead of the beginning. + Performs a case-sensitive search for a substring, but starts from the end of the string instead of the beginning. </description> </method> <method name="rfindn"> @@ -647,7 +670,7 @@ <argument index="1" name="from" type="int" default="-1"> </argument> <description> - Performs a search for a substring, but starts from the end of the string instead of the beginning. Ignores case. + Performs a case-insensitive search for a substring, but starts from the end of the string instead of the beginning. </description> </method> <method name="right"> @@ -662,16 +685,17 @@ <method name="rsplit"> <return type="PoolStringArray"> </return> - <argument index="0" name="divisor" type="String"> + <argument index="0" name="delimiter" type="String"> </argument> <argument index="1" name="allow_empty" type="bool" default="True"> </argument> <argument index="2" name="maxsplit" type="int" default="0"> </argument> <description> - Splits the string by a [code]divisor[/code] string and returns an array of the substrings, starting from right. - [b]Example:[/b] [code]"One,Two,Three"[/code] will return [code]["One","Two","Three"][/code] if split by [code]","[/code]. - If [code]maxsplit[/code] is specified, then it is number of splits to do, default is 0 which splits all the items. + Splits the string by a [code]delimiter[/code] string and returns an array of the substrings, starting from right. + The splits in the returned array are sorted in the same order as the original string, from left to right. + If [code]maxsplit[/code] is specified, it defines the number of splits to do from the right up to [code]maxsplit[/code]. The default value of 0 means that all items are split, thus giving the same result as [method split]. + For example, [code]"One,Two,Three,Four"[/code] will return [code]["Three","Four"][/code] if split by [code]","[/code] with a [code]maxsplit[/code] value of 2. </description> </method> <method name="rstrip"> @@ -683,6 +707,20 @@ Returns a copy of the string with characters removed from the right. </description> </method> + <method name="sha1_buffer"> + <return type="PoolByteArray"> + </return> + <description> + Returns the SHA-1 hash of the string as an array of bytes. + </description> + </method> + <method name="sha1_text"> + <return type="String"> + </return> + <description> + Returns the SHA-1 hash of the string as a string. + </description> + </method> <method name="sha256_buffer"> <return type="PoolByteArray"> </return> @@ -709,28 +747,28 @@ <method name="split"> <return type="PoolStringArray"> </return> - <argument index="0" name="divisor" type="String"> + <argument index="0" name="delimiter" type="String"> </argument> <argument index="1" name="allow_empty" type="bool" default="True"> </argument> <argument index="2" name="maxsplit" type="int" default="0"> </argument> <description> - Splits the string by a divisor string and returns an array of the substrings. - [b]Example:[/b] [code]"One,Two,Three"[/code] will return [code]["One","Two","Three"][/code] if split by [code]","[/code]. - If [code]maxsplit[/code] is given, at most maxsplit number of splits occur, and the remainder of the string is returned as the final element of the list (thus, the list will have at most maxsplit+1 elements) + Splits the string by a [code]delimiter[/code] string and returns an array of the substrings. + If [code]maxsplit[/code] is specified, it defines the number of splits to do from the left up to [code]maxsplit[/code]. The default value of 0 means that all items are split. + For example, [code]"One,Two,Three"[/code] will return [code]["One","Two"][/code] if split by [code]","[/code] with a [code]maxsplit[/code] value of 2. </description> </method> <method name="split_floats"> <return type="PoolRealArray"> </return> - <argument index="0" name="divisor" type="String"> + <argument index="0" name="delimiter" type="String"> </argument> <argument index="1" name="allow_empty" type="bool" default="True"> </argument> <description> - Splits the string in floats by using a divisor string and returns an array of the substrings. - [b]Example:[/b] [code]"1,2.5,3"[/code] will return [code][1,2.5,3][/code] if split by [code]","[/code]. + Splits the string in floats by using a delimiter string and returns an array of the substrings. + For example, [code]"1,2.5,3"[/code] will return [code][1,2.5,3][/code] if split by [code]","[/code]. </description> </method> <method name="strip_edges"> @@ -756,17 +794,17 @@ </return> <argument index="0" name="from" type="int"> </argument> - <argument index="1" name="len" type="int"> + <argument index="1" name="len" type="int" default="-1"> </argument> <description> - Returns part of the string from the position [code]from[/code] with length [code]len[/code]. + Returns part of the string from the position [code]from[/code] with length [code]len[/code]. Argument [code]len[/code] is optional and using -1 will return remaining characters from given position. </description> </method> <method name="to_ascii"> <return type="PoolByteArray"> </return> <description> - Converts the String (which is a character array) to [PoolByteArray] (which is an array of bytes). The conversion is sped up in comparison to [method to_utf8] with the assumption that all the characters the String contains are only ASCII characters. + Converts the String (which is a character array) to [PoolByteArray] (which is an array of bytes). The conversion is faster compared to [method to_utf8], as this method assumes that all the characters in the String are ASCII characters. </description> </method> <method name="to_float"> |