当前位置: 首页 > news >正文

哪里做网站需求企业网络宣传推广方案

哪里做网站需求,企业网络宣传推广方案,黄山旅游攻略二日游自由行攻略,徐州 网站建设如果你使用标准的依赖库执行命令中包含中文的话, 就会发现中文乱码,如果你的输出中没有中文,就可以正常输出,因为windows的命令行默认使用的是gbk编码。。。。。 #[tauri::command] pub async fn run_command(command: String) -…

如果你使用标准的依赖库执行命令中包含中文的话, 就会发现中文乱码,如果你的输出中没有中文,就可以正常输出,因为windows的命令行默认使用的是gbk编码。。。。。

#[tauri::command]
pub async fn run_command(command: String) -> Result<String, String> {#[cfg(target_os = "windows")]let output = {// 先设置控制台编码为UTF-8let _ = tokio::process::Command::new("powershell").arg("-Command").arg("chcp 65001 | Out-Null").creation_flags(0x08000000).status().await;tokio::process::Command::new("powershell").arg("-Command").arg(&command).creation_flags(0x08000000).output().await.map_err(|e| e.to_string())?};#[cfg(not(target_os = "windows"))]let output = tokio::process::Command::new("sh").arg("-c").arg(&command).output().await.map_err(|e| e.to_string())?;if output.status.success() {print!("Command output: {}",String::from_utf8_lossy(&output.stdout));Ok(String::from_utf8_lossy(&output.stdout).to_string())} else {Err(String::from_utf8_lossy(&output.stderr).to_string())}
}

解决办法

使用标准的编码依赖库encoding_rs = "0.8"

完整代码:


#[tauri::command]
pub async fn run_command(command: String) -> Result<String, String> {#[cfg(target_os = "windows")]let output = tokio::process::Command::new("powershell").arg("-Command").arg(&command).creation_flags(0x08000000).output().await.map_err(|e| e.to_string())?;#[cfg(not(target_os = "windows"))]let output = tokio::process::Command::new("sh").arg("-c").arg(&command).output().await.map_err(|e| e.to_string())?;if output.status.success() {#[cfg(target_os = "windows")]{// 在Windows上尝试从GBK转换为UTF-8let (decoded, _, _) = GBK.decode(&output.stdout);Ok(decoded.into_owned())}#[cfg(not(target_os = "windows"))]{Ok(String::from_utf8_lossy(&output.stdout).to_string())}} else {#[cfg(target_os = "windows")]{let (decoded, _, _) = GBK.decode(&output.stderr);Err(decoded.into_owned())}#[cfg(not(target_os = "windows"))]{Err(String::from_utf8_lossy(&output.stderr).to_string())}}
}

http://www.hkea.cn/news/602555/

相关文章:

  • 手机网站制作哪家好查关键词
  • 米拓企业网站管理系统电商培训机构排名前十
  • 做效果图有哪些网站seo点击排名
  • 网络营销推广网站收录seo推广排名平台有哪些
  • 产品经理如何看待网站开发广州软件系统开发seo推广
  • wordpress 忘记管理员如何做网站seo
  • app和网站哪个有优势淘宝关键词排名
  • wordpress该域名宁波网站seo公司
  • 建购物网站怎么建呀简单的网站建设
  • 江苏省建设教育协会网站首页百度知道合伙人答题兼职入口
  • 做优化的网站平台搭建
  • 做网站需要多久网络推广是什么专业
  • 厦门加盟网站建设线上推广营销
  • 定制网站案例seo搜索引擎优化薪酬
  • 网站制作成功后怎么使用浏览器观看b站视频的最佳设置
  • 一家专门做开网店的网站北京seo专员
  • 专业企业网站搭建服务头条权重查询
  • 去哪儿网站上做民宿需要材料免费的黄冈网站有哪些平台
  • 网站建设网现在推广什么app最挣钱
  • 嘉兴装修公司做网站安装百度到桌面
  • 电商网站特点外贸营销网站建站
  • 上海市住房城乡建设管理委员会网站网络营销软文范例大全800
  • 莱芜区政协网站做网络优化的公司排名
  • 太原网站建设开发公司电商运营基本知识
  • php做企业网站seo网站推广企业
  • 万网网站备案授权书免费发布推广信息的b2b
  • 乡镇可以做门户网站seo是什么意思职业
  • 建设银行网站优点做个公司网站大概多少钱
  • 网站标题的设置方法哪家建设公司网站
  • 网站空间托管电商平台的营销方式