Skip to content

Gerrard-YNWA/lua-utf8

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

utf8 functions implemented in pure lua

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages