Context:
The APEX_DATA_PARSER package provides a p_file_charset parameter, which is extremely useful for parsing files in ANSI (Windows-1252), ISO-8859-1, and other encodings. However, the APEX_DATA_EXPORT package lacks a similar option for defining the character set of the output when exporting data—especially relevant for CSV or text formats.
This limitation can cause issues when generating files for legacy systems or third-party applications that do not support UTF-8. Developers are then forced to use workarounds, such as manual conversion with tools like Notepad++, or custom PL/SQL logic.
Proposal:
Add an optional parameter p_file_charset to the apex_data_export.export procedure to allow explicit control over the output encoding of exported files.
Example Usage (CSV Export with Encoding Control):
DECLARE
l_context apex_exec.t_context;
l_export apex_data_export.t_export;
BEGIN
l_context := apex_exec.open_query_context(
p_location => apex_exec.c_location_local_db,
p_sql_query => 'select * from emp' );
l_export := apex_data_export.export (
p_context => l_context,
p_format => apex_data_export.c_format_csv,
p_file_charset => 'WE8MSWIN1252' -- ← Proposed enhancement
);
apex_exec.close( l_context );
apex_data_export.download( p_export => l_export );
EXCEPTION
when others THEN
apex_exec.close( l_context );
raise;
END;
Benefits:
- Enables compatibility with systems that require specific encodings (e.g., ANSI or Latin-1).
- Eliminates the need for external encoding conversion tools or custom PL/SQL workarounds.
- Ensures consistency with the flexibility already provided by
apex_data_parser.
- Helps deliver a better developer experience and supports broader integration use cases.