Solved

_wpopen

Posted on 2003-12-08
5
588 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

688 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