Skip to content

Commit

Permalink
docs(logic): generate documentation for string_bytes/3
Browse files Browse the repository at this point in the history
  • Loading branch information
ccamel committed Jan 7, 2024
1 parent 36fa809 commit 9767430
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions docs/predicate/predicates.md
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,36 @@ Examples:
- source_file('foo.pl').
```

## string_bytes/3

string_bytes/3 is a predicate that unifies a string with a list of bytes, returning true when the \(Unicode\) String is represented by Bytes in Encoding.

The signature is as follows:

```text
string_bytes(?String, ?Bytes, +Encoding)
```

Where:

- String is the string to convert to bytes. It can be an Atom, string or list of characters codes.
- Bytes is the list of numbers between 0 and 255 that represent the sequence of bytes.
- Encoding is the encoding to use for the conversion.

Encoding can be one of the following: \- 'text' considers the string as a sequence of Unicode characters. \- 'octet' considers the string as a sequence of bytes. \- 'utf8' considers the string as a sequence of UTF\-8 characters. \- '\<encoding\>' considers the string as a sequence of characters in the given encoding.

At least one of String or Bytes must be instantiated.

Examples:

```text
# Convert a string to a list of bytes.
- string_bytes('Hello World', Bytes, octet).
# Convert a list of bytes to a string.
- string_bytes(String, [72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100], octet).
```

## uri_encoded/3

uri_encoded/3 is a predicate that unifies the given URI component with the given encoded or decoded string.
Expand Down

0 comments on commit 9767430

Please sign in to comment.