Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Unicode version of ifstream class ?

Posted on 1997-06-19
5
Medium Priority
?
1,526 Views
Last Modified: 2013-12-14
Where can I get a Unicode equivalent to the ifstream
class (ie. using TCHAR) ?

I am using Microsoft Visual C++ 4.2
0
Comment
Question by:mongo061997
  • 3
  • 2
5 Comments
 

Author Comment

by:mongo061997
ID: 1163977
Edited text of question
0
 
LVL 4

Accepted Solution

by:
md041797 earned 200 total points
ID: 1163978
Just write an inserter and an extractor for your data type.

ostream &operator << (const TCHAR *c, ostream &out) {
    out << wstrlen (c)+1;
    out.write ((const char *)c, wstrlen (c)+1);
    return out;
    }

ostream &operator << (const TCHAR c, ostream &out) {
    out.write ((const char *)&c, sizeof (TCHAR));
    return out;
    }

istream &operator >> (TCHAR *c, istream &in) {
    int length;
    in >> length;
    in.read ((char *)c, length);
    return in;
    }

istream &operator >> (TCHAR c, istream &in) {
    in.read ((char *)&c, sizeof (TCHAR));
    return in;
    }



0
 

Author Comment

by:mongo061997
ID: 1163979
Thank you, md.
The answer was technically good, but it needs adaptation
for IFSTREAM.
0
 

Author Comment

by:mongo061997
ID: 1163980
Thank you, md.
The answer was very interesting, but I will need to adapt it
for IFSTREAM.
0
 
LVL 4

Expert Comment

by:md041797
ID: 1163981
Since ifstream is derived from istream, these extractors will work as advertised.  The complier will cast the ifstream to istream automatically, so you can write:

ifstream in;
WCHAR UniChar;
in >> UniChar;
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org Go to that link and select download selenium in the right hand column That will then direct you to their download page. From that p…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
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…
Suggested Courses
Course of the Month10 days, 20 hours left to enroll

886 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