X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=rust%2Fsrc%2Fencoding.rs;h=d22f6927477218f59f564dd6a93a8bfd79d77d3c;hb=20e2af4ec687ccbdfe47fe30275dd0121ec3ec16;hp=296e4e65a8e4f32a61e4e415318610e3180513f7;hpb=6225b13e18d6ce5b42aa7112fa44a67b13b3bb41;p=pspp diff --git a/rust/src/encoding.rs b/rust/src/encoding.rs index 296e4e65a8..d22f692747 100644 --- a/rust/src/encoding.rs +++ b/rust/src/encoding.rs @@ -6,8 +6,24 @@ pub fn codepage_from_encoding(encoding: &str) -> Option { .copied() } -pub fn encoding_from_hints(encoding: Option<&str>, codepage: Option) -> Option<&str> { - if encoding.is_some() { +use thiserror::Error as ThisError; +#[derive(ThisError, Debug)] +pub enum Error { + #[error("This system file does not indicate its own character encoding. Using default encoding {0}. For best results, specify an encoding explicitly. Use SYSFILE INFO with ENCODING=\"DETECT\" to analyze the possible encodings.")] + NoEncoding(String), + +} + +/// Returns the character set used by the locale configured in the operating +/// system. This should implement roughly the same behavior as the function +/// with the same name in Gnulib. Until then, we'll just use a default. +pub fn locale_charset() -> &'static str { + "UTF-8" +} + +/* +pub fn encoding_from_hints(encoding: Option<&str>, codepage: Option) -> Result<&str, ()> { + let label = if encoding.is_some() { encoding } else if let Some(codepage) = codepage { match codepage { @@ -24,5 +40,6 @@ pub fn encoding_from_hints(encoding: Option<&str>, codepage: Option) -> Opt } } else { None - } + }; } +*/