Skip to content

Commit 8606705

Browse files
committed
Document string.tohex & string.fromhex
1 parent 09dedc1 commit 8606705

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

docs/Runtime Environment/String.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,3 +275,29 @@ Checks if a string starts with a prefix.
275275
local s = "hello world"
276276
print(string.startswith(s, "hello")) --> true
277277
```
278+
---
279+
### `string.tohex`
280+
Converts a (binary) string to a hex representation.
281+
#### Parameters
282+
1. The string to convert.
283+
2. An optional bool to indicate that spaces should be used.
284+
3. An optional bool to indicate that the result should be upper-cased.
285+
#### Returns
286+
A new string.
287+
```pluto
288+
print("XYZ":tohex()) --> 58595a
289+
print("XYZ":tohex(true)) --> 58 59 5a
290+
print("XYZ":tohex(false, true)) --> 58595A
291+
print("XYZ":tohex(true, true)) --> 58 59 5A
292+
```
293+
---
294+
### `string.fromhex`
295+
Converts a hex string to binary.
296+
#### Parameters
297+
1. The string to convert.
298+
#### Returns
299+
A new string.
300+
```pluto
301+
print("58595a":fromhex()) --> XYZ
302+
print("58 59 5A":fromhex()) --> XYZ
303+
```

0 commit comments

Comments
 (0)