add hex_decode() to String

This commit is contained in:
bendn
2023-03-06 10:17:33 +07:00
parent 44d539465a
commit ca0feabbb0
6 changed files with 88 additions and 0 deletions

View File

@@ -296,6 +296,24 @@
[b]Note:[/b] Strings with equal hash values are [i]not[/i] guaranteed to be the same, as a result of hash collisions. On the countrary, strings with different hash values are guaranteed to be different.
</description>
</method>
<method name="hex_decode" qualifiers="const">
<return type="PackedByteArray" />
<description>
Decodes a hexadecimal string as a [PackedByteArray].
[codeblocks]
[gdscript]
var text = "hello world"
var encoded = text.to_utf8_buffer().hex_encode() # outputs "68656c6c6f20776f726c64"
print(buf.hex_decode().get_string_from_utf8())
[/gdscript]
[csharp]
var text = "hello world";
var encoded = text.ToUtf8Buffer().HexEncode(); # outputs "68656c6c6f20776f726c64"
GD.Print(buf.HexDecode().GetStringFromUtf8());
[/csharp]
[/codeblocks]
</description>
</method>
<method name="hex_to_int" qualifiers="const">
<return type="int" />
<description>