Skip to content

Commit

Permalink
Lua: add functions pandoc.text.toencoding, pandoc.text.fromencoding.
Browse files Browse the repository at this point in the history
Closes: #8512
  • Loading branch information
tarleb committed Jan 3, 2023
1 parent ce7d1d1 commit f43ddda
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
25 changes: 25 additions & 0 deletions doc/lua-filters.md
Original file line number Diff line number Diff line change
Expand Up @@ -2418,6 +2418,18 @@ function Str (s)
end
```

### fromencoding {#text.fromencoding}

`fromencoding(s, encoding)`

Converts a string to UTF-8. The `encoding` parameter specifies the
encoding of the input string. On Windows, that parameter defaults
to the current ANSI code page; on other platforms the function
will try to use the file system's encoding.

See [`toencoding`](#text.toencoding) for more info on supported
encodings.

### lower {#text.lower}

`lower (s)`
Expand Down Expand Up @@ -2449,6 +2461,19 @@ Returns the length of a UTF-8 string.
Returns a substring of a UTF-8 string, using Lua's string
indexing rules.

### toencoding {#text.toencoding}

`toencoding(s, encoding)`

Converts a UTF-8 string to a different encoding. The `encoding`
parameter defaults to the current ANSI code page on Windows; on
other platforms it will try to guess the file system's encoding.

The set of known encodings is system dependent, but includes at
least `UTF-8`, `UTF-16BE`, `UTF-16LE`, `UTF-32BE`, and `UTF-32LE`.
Note that the default code page on Windows is available through
`CP0`.

# Module pandoc

Fields and functions for pandoc scripts; includes constructors for
Expand Down
2 changes: 1 addition & 1 deletion pandoc-lua-engine/pandoc-lua-engine.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ library
, hslua-module-doclayout>= 1.0.4 && < 1.1
, hslua-module-path >= 1.0.3 && < 1.1
, hslua-module-system >= 1.0 && < 1.1
, hslua-module-text >= 1.0 && < 1.1
, hslua-module-text >= 1.0.3 && < 1.1
, hslua-module-version >= 1.0.3 && < 1.1
, hslua-module-zip >= 1.0.0 && < 1.1
, lpeg >= 1.0.1 && < 1.1
Expand Down
1 change: 1 addition & 0 deletions stack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ extra-deps:
- hslua-core-2.2.1
- hslua-list-1.1.0
- hslua-marshalling-2.2.1
- hslua-module-text-1.0.3
- hslua-module-version-1.0.3
- hslua-module-zip-1.0.0
- hslua-objectorientation-2.2.1
Expand Down

0 comments on commit f43ddda

Please sign in to comment.