Automation 4 unicode.lua

From Aegisub Manual

The unicode.lua include for Automation 4 Lua contains various helper functions for working with UTF-8 encoded text.

Contents

unicode.charwidth

Synopsis: width = unicode.charwidth(instring, index)

Returns the number of bytes occupied by the UTF-8 encoded character starting at position index in instring. The character pointed to is assumed to be a prefix byte.

The index parameter is optional, it defaults to 1 (one) when left out, meaning the width of the first character in instring will be returned.

unicode.chars

Synopsis: for char = unicode.chars(instring) do ... end

Returns an iterator function for looping over all characters in the given UTF-8 encoded string. For each iteration of the loop, char will contain a string representing the next character in the string.

unicode.len

Synopsis: length = unicode.len(instring)

Determine the length of the given UTF-8 encoded string.

Be aware that this function does not run in constant time, but in linear time (O(N)) proportional to the number of Unicode characters in instring.

unicode.codepoint

Synopsis: val = unicode.codepoint(instring)

Calculate the Unicode codepoint for the first character in instring.

Overview:

Automation Manager • Running macros • Using export filters • Standard macros • Changes from Automation 3 • Moving from Automation 3

Karaoke Templater reference:

Declaring templates • Execution order • Modifiers • Inline-variables ($-variables) • Code lines and blocks • Execution envirionment

Lua reference:

Registration • Subtitles object • Progress reporting • Config dialogues • Misc. APIs • karaskel.lua • utils.lua • unicode.lua • cleantags.lua

Karaskel concepts:

Style tables • Dialogue line tables • Syllable tables • Inline effects • Furigana

Navigation