[英]Alternatives for c++ system() on linux
I am trying to execute some scripts from within my C++ program using system()
command. 我试图使用
system()
命令从我的C ++程序中执行一些脚本。 I am aware of cons of using system to execute something outside current execution. 我知道使用系统在当前执行之外执行某些操作的弊端。
My problem is, I can do a system(path)
where path
refers to the shell script that I need to execute. 我的问题是,我可以做一个
system(path)
,其中path
指向我需要执行的shell脚本。 I am trying to work with unicode now and my path can contain japanese/chinese etc characters. 我现在尝试使用unicode,并且我的路径可以包含日文/中文等字符。 I made my path char16_t to use UTF16 encoding, but how do I call the system() now??
我将路径char16_t设置为使用UTF16编码,但是现在如何调用system()?
Any pointers appreciated. 任何指针赞赏。
也许您可以将utf16转换为utf8,然后使用system或fork和execv。
Convert the string to the encoding expected by the shell (probably UTF-8, and probably using the iconv library). 将字符串转换为外壳程序期望的编码(可能是UTF-8,并可能使用iconv库)。 Then call
system()
with it as normal. 然后像往常一样调用
system()
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.