# ASCII

A utility library to perate on ASCII strings.&#x20;

## Interface

### <mark style="color:blue;">contains</mark>

**It checks if string a contains string b.**

```rust
public fun contains(a: String, b: String): bool
```

* **@param a:** A string.&#x20;
* **@param b**: Another string
* **@return bool.** True if `a` contains `b`.&#x20;

**Aborts**

* `b` is longer than `a`.

### <mark style="color:blue;">append</mark>

**Appends `a` and `b`**

```rust
public fun append(a: String, b: String): String
```

* **@param a:** The first subtring.&#x20;
* **@param b**: The second substring.&#x20;
* **@return String.**  `b` os longer than `a` \`a\` + \`b\` => "hello" \`append\` "world" => "helloworld".&#x20;

### <mark style="color:blue;">slice</mark>

**Returns a \[i, j) slice of the string starting at index i and going up to, but not including, index j.**

```rust
public fun append(a: String, b: String): String
```

* **@param s:** The string that will be sliced.&#x20;
* **@param i:** The first index of the substring. &#x20;
* **@param j:** The last index of the substring. This character is not included.&#x20;
* **@return String.** The substring.

  &#x20;

**Aborts**

* if `j` is greater than `s`.
* if `j` is smaller than `i`.

### <mark style="color:blue;">into\_char</mark>

**It returns the `Char` at index `i` from `string`.**

```rust
public fun into_char(string: &String, i: u64): Char
```

* **@param string:** The string that contains the `Char`.
* **@param i:** i The index of the `Char` we want to grab.
* **@return Char.** The `Char` at index `i`.

**Aborts**

* `i` is out of bounds

### <mark style="color:blue;">to\_lower\_case</mark>

**It lowercases the string.**

```rust
public fun to_lower_case(string: String): String
```

* **@param string:** The string we wish to lowercase.
* **@return String**. The lowercase `string`

### <mark style="color:blue;">to\_upper\_case</mark>

**It uppercases the string.**

```rust
public fun to_upper_case(string: String): String
```

* **@param string:** The string we wish to lowercase.
* **@return String**. The lowercase `string`

### <mark style="color:blue;">u128\_to\_string</mark>

**Converts a `u128` to its `ascii::String` decimal representation.**

```rust
public fun u128_to_string(value: u128): String
```

* **@param value:** A u128.
* **@return String.** The string representation of `value`. E.g. 128 => "128".

### <mark style="color:blue;">u128\_to\_hex\_string</mark>

**Converts a `u128` to its `ascii::String` hexadecimal representation.**

```rust
public fun u128_to_hex_string(value: u128): String 
```

* **@param value:** A u128.
* **@return String.** The HEX string representation of `value`. E.g. 10 => "0xA".

### <mark style="color:blue;">u128\_to\_hex\_string\_to\_fixed\_length</mark>

**Converts a `u128` to its `ascii::String` hexadecimal representation with fixed length (in whole bytes). The returned String is `2 * length + 2`(with '0x') in size.**

```rust
public fun u128_to_hex_string_fixed_length(value: u128, length: u128): String
```

* **@param value:** A u128.
* **@param length:** length of the string.
* **@return String.** The HEX string representation of `value`. E.g. 10 => "0xA".

### <mark style="color:blue;">bytes\_to\_hex\_string</mark>

**Converts a `vector<u8>` to its `ascii::String` hexadecimal representation.**

```rust
public fun bytes_to_hex_string(bytes: vector<u8>): String
```

* **@param** value A u128.
* **@return String.** The HEX string representation of `bytes`. E.g. 0b1010 => "0x0A".

### <mark style="color:blue;">addr\_into\_string</mark>

Converts an address `addr` to its `ascii::String` representation. Addresses are 32 bytes, whereas the string-encoded address is 64 bytes. Outputted strings do not include the 0x prefix.

```rust
public fun addr_into_string(addr: address): String
```

* **@param addr**: A 32-byte address.
* **@return** String. The `ascii::String` representation of `addr`.

### <mark style="color:blue;">u8\_to\_ascii</mark>

**Converts a u8 `num` to an ascii character.**

```rust
public fun u8_to_ascii(num: u8): u8
```

* **@param num:** decimal representation of an ASCII character.
* **@return u8.** The `ascii::String` code for `num`.

### <mark style="color:blue;">ascii\_to\_u8</mark>

**Converts an ASCII character to its decimal representation u8.**

```rust
public fun ascii_to_u8(char: u8): u8
```

* **@param char:** ASCII character.
* **@return u8.** The decimal representation of `char`.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.interestprotocol.com/overview/deprecated/sui-tears/utils/ascii.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
