ctb_formats_eite/encoding.rs
1// SPDX-License-Identifier: AGPL-3.0-or-later
2/*
3This file is part of Collective Toolbox, a database and document workspace and utilities.
4Copyright (C) 2026 Collective Toolbox Developers
5Contact: info@collectivetoolbox.com
6
7This program is free software: you can redistribute it and/or modify it under
8the terms of the GNU Affero General Public License as published by the Free
9Software Foundation, either version 3 of the License, or (at your option) any
10later version.
11
12This program is distributed in the hope that it will be useful, but WITHOUT ANY
13WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
15
16You should have received a copy of the GNU Affero General Public License along
17with this program. If not, see <https://www.gnu.org/licenses/>.
18*/
19
20//! Character set and binary format encodings for EITE.
21
22use crate::utilities::*;
23use crate::{
24 dc::data::dc_data_filter_by_value, formats::is_supported_output_format,
25};
26
27pub mod ascii;
28pub mod base;
29pub mod basenb;
30pub mod pack32;
31pub mod unicode;
32pub mod utf8;
33
34pub fn list_char_encodings() -> Result<Vec<String>> {
35 dc_data_filter_by_value("formats", 6, "encoding", 1)
36}
37
38pub fn is_supported_char_encoding(fmt: &str) -> bool {
39 let Ok(encodings) = list_char_encodings() else {
40 return false;
41 };
42 encodings
43 .iter()
44 .any(|f| f == fmt && is_supported_output_format(fmt))
45}