Solved

_wpopen

Posted on 2003-12-08
5
579 Views
Last Modified: 2010-05-19
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
Comment
Question by:pb_india
  • 2
5 Comments
 
LVL 17

Expert Comment

by:rstaveley
ID: 9903449
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
 
LVL 2

Accepted Solution

by:
antoinebf earned 63 total points
ID: 9916005
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
 
LVL 17

Assisted Solution

by:rstaveley
rstaveley earned 62 total points
ID: 9916567
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now