Skip to content

Latest commit

 

History

History
93 lines (54 loc) · 1.75 KB

README.md

File metadata and controls

93 lines (54 loc) · 1.75 KB

lua-utf8

Actions Status codecov License

Name

lua-utf8, simple, lightweight utf8 lib in pure lua.

Description

This library implements several basic function for utf8 strings in pure lua with no dependency.

Methods

validate

Validate whether the given string is a valid utf8 string.

syntax: valid, invalid_pos = utf8.validate(str)

Args:

  • str: string

Returns:

  • valid (bool) whether the input string is a valid utf8 string.

  • invalid_pos (number) position of the first invalid byte in the given string.

Back to TOP

len

Get the given string len of utf8.

syntax len, invalid_pos = utf8.len(str)

Args:

  • str: string

Returns:

  • len (number) the length of valid utf8 string part.

  • invalid_pos (number) position of the first invalid byte in the given string.

Back to TOP

reverse

Reverse a given valid utf8 string.

syntax s = utf8.reverse(str)

Args:

  • str: string

Returns:

  • s (string) a reversed utf8 string of the given string.

Back to TOP

sub

Sub the given valid utf8 string with the given index.

syntax s = utf8.sub(str, s, e)

Args:

  • str: string

  • s: number, start index of utf8 character

  • e: number, end index of utf8 character

Returns:

  • s (string) utf8 sub string

Back to TOP