mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-25 18:03:37 +08:00
Rename byte encoding helper
Existing C++ code didn't use a function for this but simply added ENCODE_DIRECT_BASE. In Rust that's more verbose because char won't do arithmetics, hence the function. We'll add a dual function for decoding, so let's rename this. BTW we should get rid of the "wchar" naming, it's just "char" in Rust.
This commit is contained in:
parent
0b6605b026
commit
4f14b8dc7b
|
@ -4,7 +4,7 @@ use libc::c_int;
|
|||
|
||||
use super::shared::{builtin_missing_argument, io_streams_t, STATUS_CMD_OK, STATUS_INVALID_ARGS};
|
||||
use crate::ffi::parser_t;
|
||||
use crate::wchar::{wchar_literal_byte, wstr, WString, L};
|
||||
use crate::wchar::{encode_byte_to_char, wstr, WString, L};
|
||||
use crate::wgetopt::{wgetopter_t, woption};
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
|
@ -201,7 +201,7 @@ pub fn echo(
|
|||
{
|
||||
consumed = digits_consumed;
|
||||
// The narrow_val is a literal byte that we want to output (#1894).
|
||||
wchar_literal_byte(narrow_val)
|
||||
encode_byte_to_char(narrow_val)
|
||||
} else {
|
||||
consumed = 0;
|
||||
'\\'
|
||||
|
|
|
@ -74,7 +74,7 @@ pub const ENCODE_DIRECT_END: char = match char::from_u32(ENCODE_DIRECT_BASE as u
|
|||
/// character.
|
||||
///
|
||||
/// See https://github.com/fish-shell/fish-shell/issues/1894.
|
||||
pub fn wchar_literal_byte(byte: u8) -> char {
|
||||
pub fn encode_byte_to_char(byte: u8) -> char {
|
||||
char::from_u32(u32::from(ENCODE_DIRECT_BASE) + u32::from(byte))
|
||||
.expect("private-use codepoint should be valid char")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user