Skip to main content
Version: Next

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


isString​

â–¸ isString(value): value is string

Checks if a given value is a string.

Parameters​

NameTypeDescription
valueunknownThe value to be checked.

Returns​

value is string

  • Returns true if the value is a string, false otherwise.

Defined in​

src/utils/shortString.ts:33


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:40


splitLongString​

â–¸ splitLongString(longStr): string[]

Split long text into short strings

Parameters​

NameType
longStrstring

Returns​

string[]

Defined in​

src/utils/shortString.ts:57


encodeShortString​

â–¸ encodeShortString(str): string

Convert an ASCII string to a hexadecimal string.

Parameters​

NameTypeDescription
strstringshort string (ASCII string, 31 characters max)

Returns​

string

format: hex-string; 248 bits max

Example

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

Defined in​

src/utils/shortString.ts:72


decodeShortString​

â–¸ decodeShortString(str): string

Convert a hexadecimal or decimal string to an ASCII string.

Parameters​

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

Returns​

string

format: short string; 31 characters max

Example

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

Defined in​

src/utils/shortString.ts:88


isShortText​

â–¸ isShortText(val): boolean

Test if value is short text

Parameters​

NameType
valany

Returns​

boolean

Defined in​

src/utils/shortString.ts:47


isLongText​

â–¸ isLongText(val): boolean

Test if value is long text

Parameters​

NameType
valany

Returns​

boolean

Defined in​

src/utils/shortString.ts:52