Interest Protocol
  • 👋Welcome to Interest Protocol
  • Overview
    • Sui💧
      • Contracts
        • Memez
        • Libs 📚
      • Suicoins
        • Swap
        • Dollar-Cost Averaging (DCA)
        • Airdrop
          • Suiplay Airdrop
        • Incinerator
        • Send
        • Merger
        • Suicoins Terminal
      • Memez.gg
        • Coins on Memez.GG
        • Memez.Fun
          • SDK
            • Pump API
            • Interfaces
          • Configuration
          • Migrators
          • Bonding Curve
          • Fees
      • IPX Coin Standard
    • Movement
      • Interest Protocol Decentralized Exchange (DEX)
        • Key Features
        • Core Innovations
      • sr-AMM
      • Token
        • Tokenomics
        • Utility
      • GTM
    • Audits
    • Security
    • Deprecated
      • Coin X Oracle 🔮
        • Pyth Network
        • Switchboard
      • Sui Tears 💧
        • Airdrop
          • Airdrop
          • Airdrop Utils
          • Linear Vesting Airdrop
        • Capabilities
          • Access Control
          • Owner
          • Quest
          • Timelock
        • Collections
          • Bitmap
          • Coin Decimals
        • DeFi
          • Oracle
          • Farm
          • Fund
          • Linear Vesting Wallet
          • Linear Clawback Vesting Wallet
          • Vesting
        • Governance
          • DAO
          • DAO Admin
          • DAO Treasury
        • Utils
          • ASCII
          • Comparator
          • Merkle Proof
          • Vectors
        • Math
          • Fixed Point 64
          • Fixed Point Roll
          • Fixed Point Wad
          • Int
          • Math64
          • Math128
          • Math256
      • CLAMM🐚
        • Hooks
      • Whitepapers
  • Glossary
Powered by GitBook
On this page
  • Interface
  • contains
  • append
  • slice
  • into_char
  • to_lower_case
  • to_upper_case
  • u128_to_string
  • u128_to_hex_string
  • u128_to_hex_string_to_fixed_length
  • bytes_to_hex_string
  • addr_into_string
  • u8_to_ascii
  • ascii_to_u8

Was this helpful?

Export as PDF
  1. Overview
  2. Deprecated
  3. Sui Tears 💧
  4. Utils

ASCII

A utility library to perate on ASCII strings.

Interface

contains

It checks if string a contains string b.

public fun contains(a: String, b: String): bool
  • @param a: A string.

  • @param b: Another string

  • @return bool. True if a contains b.

Aborts

  • b is longer than a.

append

Appends a and b

public fun append(a: String, b: String): String
  • @param a: The first subtring.

  • @param b: The second substring.

  • @return String. b os longer than a `a` + `b` => "hello" `append` "world" => "helloworld".

slice

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

public fun append(a: String, b: String): String
  • @param s: The string that will be sliced.

  • @param i: The first index of the substring.

  • @param j: The last index of the substring. This character is not included.

  • @return String. The substring.

Aborts

  • if j is greater than s.

  • if j is smaller than i.

into_char

It returns the Char at index i from string.

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

to_lower_case

It lowercases the string.

public fun to_lower_case(string: String): String
  • @param string: The string we wish to lowercase.

  • @return String. The lowercase string

to_upper_case

It uppercases the string.

public fun to_upper_case(string: String): String
  • @param string: The string we wish to lowercase.

  • @return String. The lowercase string

u128_to_string

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

public fun u128_to_string(value: u128): String
  • @param value: A u128.

  • @return String. The string representation of value. E.g. 128 => "128".

u128_to_hex_string

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

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".

u128_to_hex_string_to_fixed_length

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.

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".

bytes_to_hex_string

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

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".

addr_into_string

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.

public fun addr_into_string(addr: address): String
  • @param addr: A 32-byte address.

  • @return String. The ascii::String representation of addr.

u8_to_ascii

Converts a u8 num to an ascii character.

public fun u8_to_ascii(num: u8): u8
  • @param num: decimal representation of an ASCII character.

  • @return u8. The ascii::String code for num.

ascii_to_u8

Converts an ASCII character to its decimal representation u8.

public fun ascii_to_u8(char: u8): u8
  • @param char: ASCII character.

  • @return u8. The decimal representation of char.

PreviousUtilsNextComparator

Last updated 1 year ago

Was this helpful?