Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/cosh-ng/crates/cosh-core/src/tool/grep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,9 @@ fn decode_utf16(raw: &[u8], little_endian: bool) -> (Vec<u8>, u64) {

fn decode_utf16_bytes(bytes: &[u8], little_endian: bool) -> String {
Comment thread
jfeng18 marked this conversation as resolved.
let units = bytes
.chunks_exact(2)
.as_chunks::<2>()
.0
.iter()
.map(|bytes| read_utf16_unit([bytes[0], bytes[1]], little_endian))
.collect::<Vec<_>>();
let has_partial_unit = bytes.len() & 1 == 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,9 @@ mod tests {
fn decode_hex(value: &str) -> Vec<u8> {
Comment thread
jfeng18 marked this conversation as resolved.
value
.as_bytes()
.chunks_exact(2)
.as_chunks::<2>()
.0
.iter()
.map(|pair| {
let text = std::str::from_utf8(pair).unwrap();
u8::from_str_radix(text, 16).unwrap()
Expand Down
Loading