Functions providing basic support for UTF-8 encodings
Prior to upgrading Hammerspoon's Lua interpreter to 5.3, UTF8 support was provided by including the then beta version of Lua 5.3's utf8 library as a Hammerspoon module. This is no longer necessary, but to maintain compatibility, the Lua utf8 library can still be accessed through hs.utf8. The documentation for the utf8 library can be found at http://www.lua.org/manual/5.3/ or from the Hammerspoon console via the help command: help.lua.utf8. This affects the following functions and variables:
help.lua.utf8.charhelp.lua.utf8.charpatternhelp.lua.utf8.codepointhelp.lua.utf8.codeshelp.lua.utf8.lenhelp.lua.utf8.offsetAdditional functions that are specific to Hammerspoon which provide expanded support for UTF8 are documented here.
| Signature | hs.utf8.registeredKeys[] |
|---|---|
| Type | Variable |
| Description | A collection of UTF-8 characters already converted from codepoint and available as convient key-value pairs. UTF-8 printable versions of common Apple and OS X special keys are predefined and others can be added with Predefined keys include:
Notes:
|
| Signature | hs.utf8.asciiOnly(string[, all]) -> string |
|---|---|
| Type | Function |
| Description | Returns the provided string with all non-printable ascii characters escaped, except Return, Linefeed, and Tab. Parameters:
Returns:
Notes:
|
| Signature | hs.utf8.codepointToUTF8(...) -> string |
|---|---|
| Type | Function |
| Description | Wrapper to Parameters:
Returns:
Notes:
|
| Signature | hs.utf8.fixUTF8(inString[, replacementChar]) -> outString, posTable |
|---|---|
| Type | Function |
| Description | Replace invalid UTF8 character sequences in Parameters:
Returns:
Notes:
|
| Signature | hs.utf8.hexDump(inputString [, count]) -> string |
|---|---|
| Type | Function |
| Description | Returns a hex dump of the provided string. This is primarily useful for examining the exact makeup of binary data contained in a Lua String as individual bytes for debugging purposes. Parameters:
Returns:
Notes:
|
| Signature | hs.utf8.registerCodepoint(label, codepoint) -> string |
|---|---|
| Type | Function |
| Description | Registers a Unicode codepoint under the given label as a UTF-8 string of bytes which can be referenced by the label later in your code as Parameters:
Returns:
Notes:
|
| Signature | hs.utf8.registeredLabels(utf8char) -> string |
|---|---|
| Type | Function |
| Description | Returns the label name for a UTF8 character, as it is registered in Parameters:
Returns:
Notes:
|