Wednesday, July 9, 2014

Re: Clean string returned by windows console cmd

Thank you everybody. A lot

On Wednesday, July 9, 2014 2:22:12 PM UTC+2, Christian Brabandt wrote:
> Am 2014-07-09 00:16, schrieb John Beckett:
>
> > Ni Va wrote:
>
> >> This is obtained by launching this command :
>
> >> echo system("wmic logicaldisk get deviceid")
>
> >
>
> > The problem is that the output from wmic is Unicode, and system
>
> > is dumping the bytes. I don't know how to avoid that, but the
>
> > following reads the plain text if you have the correct settings:
>
>
>
> correct. More specifically, the output is - I think - utf-16 (or was it
>
> UCS-2?)
>
> but instead of leaving the null bytes alone, Vim converts those to SOH
>
> (0x01).
>
> That's why you see all those ^A characters there (plus the BOM in the
>
> beginning
>
> of the string, so you can't even convert it on the fly using iconv() or
>
> such).
>
>
>
> I think Vim should try to convert the output of the system command.
>
> There is an entry in the todo list about it.
>
>
>
> A simple work around is, to pipe the output through findstr. So this
>
> should work:
>
>
>
> :echo system("wmic logicaldisk get deviceid|findstr '.*'")
>
>
>
> Alternatively, you might be able to script something using systemlist()
>
> and iconv()
>
>
>
> Best,
>
> Christian

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: