• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 600
  • Last Modified:

_wpopen

I am working with C++ and dll (d link lib). Its NOT EXE but DLL.
I have to read french characters that are generated when I execute a command line.
I was trying to use _wpopen but in vain.
Could you pls tell me:

1. What command in C++ would let me execute command line utilities so I can read them.
2. I am working with different languages so I am looking for something that is unicode based.

Thanks.
0
pb_india
Asked:
pb_india
  • 2
2 Solutions
 
rstaveleyCommented:
The only reason to use _wpopen is if your command is a wide character string. The returned FILE * is the same for _wpopen as it is for _popen, containing the standard output from your command.

Like a lot of experts at EE, I'm relatively weak at i18n, because I work in a locale in which 8-bit *external* representations are used. The idea of having > 8 bit standard output is weird to me... but presumably that's what you get in locals which require > 8 bit external representation for the required character set? wchar_t streams are externally represented as char streams in my locale. I don't get to see 16-bit characters on standard output from console programs, because characters are narrowed to 8 bits. If I were to write a program which outputs raw 16-bit UNICODE, I would need to open a file in binary mode. Presumably, I'd need to make the first bytes correspond to a BOM (= byte order marker). I'd certainly need to pass a binary flag to _open to get a byte stream from the command, if the UNICODE was being written to standard output, and then read wchar_ts from the byte stream.

Sorry I can't be more helpful.... but I am interested in whatever solution you find.
0
 
antoinebfCommented:
FYI, french does not require unicode support to be read/writen... ASCII is more than sufficient.

BTW, unicode is an encoding system used to represent almost any character. The encoding can span many bytes (multi byte representation). On the other hand, wide string (wopen, wstring, etc.) always use 2 bytes to represent chars (double byte representation).

All that to say that unicode and wide strings are not the same, and not fully compatible out of the box.

Have a look at:
http://www.unicode.org/

As for your questions:
1 - The win32 api call "int system(char*)" allows you to execute command line statements from within a C++ program.
2 - If windows is an option, their MFC's CString supports Unicode and might be of some help.

hth
A.
0
 
rstaveleyCommented:
I hadn't spotted the fact that pb_india was reading French characters. The name pb_india got me into Asian-think :-)

When I type chcp at a CMD prompt here in the UK, I see my codepage is 437 (which is described here: http://www.kostis.net/charsets/cp437.htm). I believe this is the same codepage as France and the US, from the DOS table at http://www.thur.de/~igs/USEFULL/OPENDOS/usrgeng/17ugch17.htm#390. If pb_india has the same codepage for his console applications, I'd agree with antoinebf and not expect the French characters captured by _popen to require translation.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now