diff --git a/todo_list/shell/shell.patch b/todo_list/shell/shell.patch new file mode 100644 index 0000000000000000000000000000000000000000..50e3f3500fee95086a644688d26bd1fab0a70a5b --- /dev/null +++ b/todo_list/shell/shell.patch @@ -0,0 +1,76 @@ +diff --git a/hdc_rust/src/cffi/utils.cpp b/hdc_rust/src/cffi/utils.cpp +index 5f11c68..5f6b92c 100644 +--- a/hdc_rust/src/cffi/utils.cpp ++++ b/hdc_rust/src/cffi/utils.cpp +@@ -44,6 +44,20 @@ constexpr uint16_t BUF_SIZE_SMALL = 256; + #endif + + extern "C" { ++ void SetConsoleUTF8() ++ { ++#ifdef _WIN32 ++ SetConsoleOutputCP(CP_UTF8); ++ SetConsoleCP(CP_UTF8); ++#endif ++ } ++ ++ void PrintMessage(char *buf, size_t len) ++ { ++ fwrite(buf, 1, len, stdout); ++ fflush(stdout); ++ } ++ + static char GetPathSep() + { + #ifdef _WIN32 +diff --git a/hdc_rust/src/host/main.rs b/hdc_rust/src/host/main.rs +index de77326..d811f32 100644 +--- a/hdc_rust/src/host/main.rs ++++ b/hdc_rust/src/host/main.rs +@@ -34,6 +34,7 @@ use std::{ + use hdc::common::base; + use hdc::common::base::Base; + use hdc::config; ++use hdc::utils; + + #[cfg(feature = "host")] + extern crate ylong_runtime_static as ylong_runtime; +@@ -66,6 +67,9 @@ fn setup_panic_hook() { + } + + fn main() { ++ unsafe { ++ utils::SetConsoleUTF8(); ++ } + setup_panic_hook(); + let _ = ylong_runtime::builder::RuntimeBuilder::new_multi_thread() + .worker_stack_size(16 * 1024 * 1024) +diff --git a/hdc_rust/src/utils.rs b/hdc_rust/src/utils.rs +index 8226c07..dc05042 100644 +--- a/hdc_rust/src/utils.rs ++++ b/hdc_rust/src/utils.rs +@@ -26,6 +26,11 @@ use std::time::{SystemTime, UNIX_EPOCH}; + extern crate ylong_runtime_static as ylong_runtime; + use ylong_runtime::io::AsyncWriteExt; + ++extern "C" { ++ fn SetConsoleUTF8(); ++ fn PrintMessage(buf: *const libc::c_char, size: i32); ++} ++ + pub fn get_pseudo_random_u32() -> u32 { + (SystemTime::now() + .duration_since(UNIX_EPOCH) +@@ -42,9 +47,9 @@ pub fn get_current_time() -> u64 { + } + + pub async fn print_msg(buf: Vec) -> io::Result<()> { +- let mut stdout = ylong_runtime::io::stdout(); +- let _ = stdout.write(&buf).await; +- let _ = stdout.flush().await; ++ unsafe { ++ PrintMessage(buf.as_ptr() as *const libc::c_char, buf.len()); ++ } + Ok(()) + } + diff --git a/todo_list/shell/todo.md b/todo_list/shell/todo.md new file mode 100644 index 0000000000000000000000000000000000000000..77deb99e0c376e81173904ccb8682d49ba831bdd --- /dev/null +++ b/todo_list/shell/todo.md @@ -0,0 +1,4 @@ +shell完成情况如下: +- 中文UTF8 +- 打印速率优化 +