Skip to main content
Version: 5.24.3

Namespace: shortString

Functions​

isASCII​

â–¸ isASCII(str): boolean

Test if string contains only ASCII characters (string can be ascii text)

Parameters​

NameType
strstring

Returns​

boolean

Defined in​

src/utils/shortString.ts:8


isShortString​

â–¸ isShortString(str): boolean

Test if string is a Cairo short string (string has less or equal 31 characters)

Parameters​

NameType
strstring

Returns​

boolean

Defined in​

src/utils/shortString.ts:16


isDecimalString​

â–¸ isDecimalString(str): boolean

Test if string contains only numbers (string can be converted to decimal number)

Parameters​

NameType
strstring

Returns​

boolean

Defined in​

src/utils/shortString.ts:23


isText​

â–¸ isText(val): boolean

Test if value is a free-from string text, and not a hex string or number string

Parameters​

NameType
valany

Returns​

boolean

Defined in​

src/utils/shortString.ts:30


splitLongString​

â–¸ splitLongString(longStr): string[]

Split long text into short strings

Parameters​

NameType
longStrstring

Returns​

string[]

Defined in​

src/utils/shortString.ts:47


encodeShortString​

â–¸ encodeShortString(str): string

Convert an ASCII string to a hexadecimal string.

Example

const myEncodedString: string = encodeShortString('uri/pict/t38.jpg');
// return hex string (ex."0x7572692f706963742f7433382e6a7067")

Parameters​

NameTypeDescription
strstringshort string (ASCII string, 31 characters max)

Returns​

string

format: hex-string; 248 bits max

Defined in​

src/utils/shortString.ts:62


decodeShortString​

â–¸ decodeShortString(str): string

Convert a hexadecimal or decimal string to an ASCII string.

Example

const myDecodedString: string = decodeShortString('0x7572692f706963742f7433382e6a7067');
// return string (ex."uri/pict/t38.jpg")

Parameters​

NameTypeDescription
strstringrepresenting a 248 bit max number (ex. "0x1A4F64EA56" or "236942575435676423")

Returns​

string

format: short string; 31 characters max

Defined in​

src/utils/shortString.ts:78


isShortText​

â–¸ isShortText(val): boolean

Test if value is short text

Parameters​

NameType
valany

Returns​

boolean

Defined in​

src/utils/shortString.ts:37


isLongText​

â–¸ isLongText(val): boolean

Test if value is long text

Parameters​

NameType
valany

Returns​

boolean

Defined in​

src/utils/shortString.ts:42