1 use alloc::string::String; 2 use core::char::REPLACEMENT_CHARACTER; 3 4 /// FAT文件系统保留开头的2个簇 5 pub const RESERVED_CLUSTERS: u32 = 2; 6 7 /// @brief 将u8转为ascii字符。 8 /// 当转码成功时,返回对应的ascii字符,否则返回Unicode占位符 9 pub(super) fn decode_u8_ascii(value: u8) -> char { 10 if value <= 0x7f { 11 return value as char; 12 } else { 13 // 如果不是ascii字符,则返回Unicode占位符 U+FFFD 14 return REPLACEMENT_CHARACTER; 15 } 16 } 17 18 /// 把名称转为inode缓存里面的key 19 #[inline(always)] 20 pub(super) fn to_search_name(name: &str) -> String { 21 name.to_ascii_uppercase() 22 } 23 24 /// 把名称转为inode缓存里面的key(输入为string,原地替换) 25 #[inline(always)] 26 pub(super) fn to_search_name_string(mut name: String) -> String { 27 name.make_ascii_uppercase(); 28 name 29 } 30