diff --git a/fish-rust/src/builtins/printf.rs b/fish-rust/src/builtins/printf.rs index 55f662ee7..9b84f4230 100644 --- a/fish-rust/src/builtins/printf.rs +++ b/fish-rust/src/builtins/printf.rs @@ -53,9 +53,9 @@ use std::result::Result; use crate::builtins::shared::{io_streams_t, STATUS_CMD_ERROR, STATUS_CMD_OK, STATUS_INVALID_ARGS}; -use crate::common::ENCODE_DIRECT_BASE; use crate::ffi::parser_t; use crate::locale::{get_numeric_locale, Locale}; +use crate::wchar::ENCODE_DIRECT_BASE; use crate::wchar::{wstr, WExt, WString, L}; use crate::wutil::errors::Error; use crate::wutil::gettext::{wgettext, wgettext_fmt}; @@ -632,7 +632,7 @@ fn print_esc(&mut self, escstart: &wstr, octal_0: bool) -> usize { self.fatal_error(wgettext!("missing hexadecimal number in escape")); } self.append_output( - char::from_u32(ENCODE_DIRECT_BASE + esc_value % 256) + char::from_u32(ENCODE_DIRECT_BASE as u32 + esc_value % 256) .expect("Escape should be encodeable"), ); } else if is_octal_digit(p.char_at(0)) { @@ -649,7 +649,7 @@ fn print_esc(&mut self, escstart: &wstr, octal_0: bool) -> usize { p = &p[1..]; } self.append_output( - char::from_u32(ENCODE_DIRECT_BASE + esc_value % 256) + char::from_u32(ENCODE_DIRECT_BASE as u32 + esc_value % 256) .expect("Escape should be encodeable"), ); } else if "\"\\abcefnrtv".contains(p.char_at(0)) { diff --git a/fish-rust/src/common.rs b/fish-rust/src/common.rs index 0717accb3..b1a951142 100644 --- a/fish-rust/src/common.rs +++ b/fish-rust/src/common.rs @@ -107,16 +107,6 @@ fn drop(&mut self) { unsafe { ManuallyDrop::drop(&mut self.captured) }; } } -// These are in the Unicode private-use range. We really shouldn't use this -// range but have little choice in the matter given how our lexer/parser works. -// We can't use non-characters for these two ranges because there are only 66 of -// them and we need at least 256 + 64. -// -// Note: We don't use the highest 8 bit range (0xF800 - 0xF8FF) because we know -// of at least one use of a codepoint in that range: the Apple symbol (0xF8FF) -// on Mac OS X. See http://www.unicode.org/faq/private_use.html. -pub const ENCODE_DIRECT_BASE: u32 = 0xF600; -pub const ENCODE_DIRECT_END: u32 = ENCODE_DIRECT_BASE + 256; /// A scoped manager to save the current value of some variable, and optionally set it to a new /// value. When dropped, it restores the variable to its old value. diff --git a/fish-rust/src/wchar.rs b/fish-rust/src/wchar.rs index 5e6be70b1..4e2f9f75f 100644 --- a/fish-rust/src/wchar.rs +++ b/fish-rust/src/wchar.rs @@ -61,8 +61,8 @@ macro_rules! L { // Note: We don't use the highest 8 bit range (0xF800 - 0xF8FF) because we know // of at least one use of a codepoint in that range: the Apple symbol (0xF8FF) // on Mac OS X. See http://www.unicode.org/faq/private_use.html. -const ENCODE_DIRECT_BASE: char = '\u{F600}'; -const ENCODE_DIRECT_END: char = match char::from_u32(ENCODE_DIRECT_BASE as u32 + 256) { +pub const ENCODE_DIRECT_BASE: char = '\u{F600}'; +pub const ENCODE_DIRECT_END: char = match char::from_u32(ENCODE_DIRECT_BASE as u32 + 256) { Some(c) => c, None => panic!("private use codepoint in encode direct region should be valid char"), };