Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Unicode version of ifstream class ?

Posted on 1997-06-19
5
Medium Priority
?
1,512 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
[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
  • 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

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
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…

660 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