From: Hector Santos on
Learn something new there.

But it doesn't seem to work. a wrapper exe will do the string.

Joseph M. Newcomer wrote:

> THere is a /u switch to cmd that I was once told about, but I have not looked it up to see
> what it does; I was told it (at least) causes the output to be in Unicode, but I have no
> idea if it has any other effects.
>
> I would be very surprised if it could handle UTF-8 encoded batch files, BOM or not. UTF-16
> would be the best we could hope for.
> joe


>
> On Mon, 12 Apr 2010 02:15:07 -0700, "Mihai N." <nmihai_year_2000(a)yahoo.com> wrote:
>
>>> I'm working on an app that (among other things) writes batch files.
>>> Presently, the batch files are UTF-8 encoded, with BOM. The batch files
>>> work properly unless they include non-ANSI characters.
>> The command line does not properly support Unicode batch files.
>> And most of the command line tools don't understand Unicode either.
>> The only solution is to try something else than the regular cmd.
>> For instance PowerShell, or VB/JavaScript scripts.
> Joseph M. Newcomer [MVP]
> email: newcomer(a)flounder.com
> Web: http://www.flounder.com
> MVP Tips: http://www.flounder.com/mvp_tips.htm



--
HLS
From: Mihai N. on
> I was hoping I would have to resort to this, but the best answer may be
> to write a mini-app that reads .bat files, then calls CreateProcess.
> PowerShell can't be assumed to be installed on user machines.

Depends what you call with CreateProcess.
As Joe was saying, /u might also help a bit.
But in the end it is not only cmd.exe, there are all the extras
that you normally call from a batch file (xcopy, fc, sort, chkdsk,
net, ipconfig, etc.) So depending what you need, might work, or might not.



--
Mihai Nita [Microsoft MVP, Visual C++]
http://www.mihai-nita.net
------------------------------------------
Replace _year_ with _ to get the real email

From: Liviu on
"Joseph M. Newcomer" <newcomer(a)flounder.com> wrote...
> THere is a /u switch to cmd that I was once told about, but I have
> not looked it up to see what it does; I was told it (at least) causes
> the output to be in Unicode

That's all it does. For example "cmd /c /u dir >file.txt" will save a
UTF-16 LE (no BOM) file. Without "/u" the file would be saved
as single-byte using the current (chcp) console codepage.

The limitation to non-Unicode batch files seems to be strictly a matter
of reading/parsing the file - and one of those "what were they thinking"
wonders ;-) The interpreter itself appears to be fully Unicode, that's
why "passthrough" strings (such as those passed on the command line
to the batch, or retrieved at runtime with "for" loops) work fine.
Incidentally, the former is what allows batch files to be used in the
"Send To" menu/folder and launch other applications even when the
target pathname contains characters outside the default codepages.

Liviu