pub fn text_display_width(text: &str) -> usizeExpand description
Calculate the display width of a string considering Chinese/English character differences.
Chinese characters typically take 2 terminal columns while ASCII characters take 1. This function provides accurate width calculation for mixed Chinese/English text.
§Arguments
text- The text to measure
§Returns
The display width in terminal columns
§Examples
use cc_switch::cli::display_utils::text_display_width;
assert_eq!(text_display_width("Hello"), 5); // 5 ASCII chars = 5 columns
assert_eq!(text_display_width("你好"), 4); // 2 Chinese chars = 4 columns
assert_eq!(text_display_width("Hello你好"), 9); // 5 ASCII + 2 Chinese = 9 columns