> For the complete documentation index, see [llms.txt](https://docs.kuthulu.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.kuthulu.xyz/contracts/kutils.md).

# KUtils

KUTHULU Utilities. This is a shared library of commonly used functions.

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

Joins five strings together.

```javascript
let a = 'Hello';
let b = ' my';
let c = ' name';
let d = ' is';
let e = ' John';
let result = contract.append(a, b, c, d, e);
```

**Input**

| Name          | Type   | Description                     |
| ------------- | ------ | ------------------------------- |
| a, b, c, d, e | string | The strings to be concatenated. |

**Output**

| Name         | Type   | Description              |
| ------------ | ------ | ------------------------ |
| return value | string | The concatenated string. |

## <mark style="color:purple;">\_toLower</mark>

Converts all uppercase characters in a string to lowercase.

```javascript
let str = 'Hello World';
let result = contract._toLower(str);
```

**Input**

| Name | Type   | Description                 |
| ---- | ------ | --------------------------- |
| str  | string | The string to be converted. |

**Output**

| Name         | Type   | Description           |
| ------------ | ------ | --------------------- |
| return value | string | The converted string. |

## <mark style="color:purple;">strlen</mark>

Returns the length of a given string.

```javascript
let str = 'Hello World';
let result = contract.strlen(str);
```

**Input**

| Name | Type   | Description                   |
| ---- | ------ | ----------------------------- |
| str  | string | The string to get the length. |

**Output**

| Name         | Type    | Description               |
| ------------ | ------- | ------------------------- |
| return value | uint256 | The length of the string. |

## <mark style="color:purple;">stringsEqual</mark>

Compares two strings for equality.

```javascript
let str1 = 'Hello';
let str2 = 'Hello';
let result = contract.stringsEqual(str1, str2);
```

**Input**

| Name | Type   | Description                 |
| ---- | ------ | --------------------------- |
| a, b | string | The strings to be compared. |

**Output**

| Name         | Type | Description                                     |
| ------------ | ---- | ----------------------------------------------- |
| return value | bool | True if the strings are equal, false otherwise. |

## <mark style="color:purple;">URI and String Validation</mark>

#### isValidURI

Checks if the given string is a valid URI according to RFC3986 URI Generic Syntax.

```javascript
let str = 'https://example.com';
let result = contract.isValidURI(str);
```

**Input**

| Name | Type   | Description               |
| ---- | ------ | ------------------------- |
| str  | string | The string to be checked. |

**Output**

| Name         | Type | Description                                         |
| ------------ | ---- | --------------------------------------------------- |
| return value | bool | True if the string is a valid URI, false otherwise. |

## <mark style="color:purple;">isValidGroupString</mark>

Checks if the given string is a valid group string.

```javascript
let str = 'HelloWorld';
let result = contract.isValidGroupString(str);
```

**Input**

| Name | Type   | Description               |
| ---- | ------ | ------------------------- |
| str  | string | The string to be checked. |

**Output**

| Name         | Type | Description                                                  |
| ------------ | ---- | ------------------------------------------------------------ |
| return value | bool | True if the string is a valid group string, false otherwise. |

## <mark style="color:purple;">isValidString</mark>

Checks if the given string is a valid string.

```javascript
let str = 'HelloWorld';
let result = contract.isValidString(str);
```

**Input**

| Name | Type   | Description               |
| ---- | ------ | ------------------------- |
| str  | string | The string to be checked. |

**Output**

| Name         | Type | Description                                   |
| ------------ | ---- | --------------------------------------------- |
| return value | bool | True if the string is valid, false otherwise. |

## <mark style="color:purple;">Integer to String Conversion</mark>

#### toString

Converts a uint256 value to its string representation.

```javascript
let value = 123456;
let result = contract.toString(value);
```

**Input**

| Name  | Type    | Description                |
| ----- | ------- | -------------------------- |
| value | uint256 | The value to be converted. |

**Output**

| Name         | Type   | Description                                   |
| ------------ | ------ | --------------------------------------------- |
| return value | string | The string representation of the input value. |

## <mark style="color:purple;">addressToString</mark>

Converts an Ethereum address to its string representation.

```javascript
let addr = '0x742d35Cc6634C0532925a3b844Bc454e4438f44e';
let result = contract.addressToString(addr);
```

**Input**

| Name | Type    | Description                  |
| ---- | ------- | ---------------------------- |
| addr | address | The address to be converted. |

**Output**

| Name         | Type   | Description                                     |
| ------------ | ------ | ----------------------------------------------- |
| return value | string | The string representation of the input address. |
