output-file-encoding
The output-file-encoding
global parameter is a string that determines which character encoding to use when writing Liquibase command outputs to external files. By default, it is set to UTF-8.
Uses
If you need to send the output of a Liquibase command like generate-changelog command, update-sql command, or diff command to a text file that does not use UTF-8, you must specify the correct character encoding. This ensures that all symbols in your file display correctly.
Alternative or legacy character encodings include US-ASCII, Windows-1252, UTF-16, and others.
Setting the output-file-encoding
parameter
You can set output-file-encoding
in four ways:
- In the Liquibase properties file
- As a global parameter in the CLI
- As a JVM system property
- As an environment variable (Liquibase Pro)
Liquibase properties file parameter
In Liquibase 4.1+, add the following to Liquibase properties file:
liquibase.outputFileEncoding
: <string>
CLI global parameter
In your command line, use a global parameter with a single Liquibase command:
liquibase --output-file-encoding
=<string>
update
--changelog-file=dbchangelog.xml
Java system property
In your command line, use the JAVA_OPTS Environment Variable to set a JVM system property:
Mac/Linux syntax:
JAVA_OPTS=-Dliquibase.outputFileEncoding
=<string>
Windows syntax:
set JAVA_OPTS=-Dliquibase.outputFileEncoding
=<string>
Note: To use a Liquibase command alongside JAVA_OPTS
, add && liquibase <command>
to the end of your input.
Environment variable (Liquibase Pro)
In Liquibase Pro, set an environment variable:
Mac/Linux syntax:
LIQUIBASE_OUTPUT_FILE_ENCODING
=<string>
Windows syntax:
set LIQUIBASE_OUTPUT_FILE_ENCODING
=<string>
Note: These environment variable commands only apply to the current shell. If you need to pass an environment variable to a child process without affecting the parent process, you can use the export
command on Mac/Linux or the setx
command on Windows.