Solved

Win32 Unicode Compatibility for Win95/98

Posted on 1998-08-29
6
310 Views
Last Modified: 2010-04-02
I'm planning on migrating my Win32 app to Unicode, but need to maintain compatibility with Win95/98 in a single executable.  Although the C Runtime Library Unicode functions (wcslen, wprintf etc.) are all supported in both NT and Win95/98, the Win32 library functions are not - the Windows 95/98 implementation of these functions only accept ANSI characters and no Unicode.

Question is:  Is there an easy way to implement this Win95/98 and NT Unicode support in a single executable?  The only way I can think of is to create my own "wrapper" functions for all Win32 calls, and to conditionally convert the arguments/returns to/from Unicode based on whether I'm running Win95/98.  Has anyone done this and wants to share their code?  Is there a pre-written library that I can buy or download that provides this conversion?

Surely I'm not the first to come across this huge limitation in Win95 and Win98!  I'm happy to give more points if you have a good solution!
0
Comment
Question by:tphipps
6 Comments
 
LVL 3

Expert Comment

by:xyu
Comment Utility
Use MultiByteToWideChar & WideCharToMultiByte fuctions...

or You can go to http://www.geocities.com/SiliconValley/1741/
download Natlib template library... and look at nlstring.h/nlstring.cpp for SzToWide, SzToStd, etc. functions to convert between UNICODE/ASCII ....
0
 

Author Comment

by:tphipps
Comment Utility
Good try xyu, but not what I'm looking for.  Converting the text from native to Unicode and vice-versa is not the problem.  The problem is the fact that I'd need to write a routine to do this for every one of the hundreds of Win32 function calls in order to get Win95 support.

Surely there's a better way...
0
 
LVL 1

Expert Comment

by:Arkadiy
Comment Utility
Can you please be more specific? What functions are missing? I use Unicode for user-readable output, and TextOutW is indeed supported in 95 as well as in NT.

In case you _really_ need a solution, what about your own string class? it can return different string depending on the context:

class CMyString
{
...
   operator const char*(){return Ansi string}
   operator const WCHAR *(){return Unicode string}
...
}

You can even derive it from MFC strings, if you wish
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 13

Accepted Solution

by:
Mirkwood earned 50 total points
Comment Utility
Whether you like it or not. Win95 & 98 do not support UNICODE.
Altough most functions are defined in win95/win98, they are just not implemented and return OK.
Officially win95/win98 were meant for users at home and not in office environments.
Win95/win98 does however support DBCS. Double byte Character system. That means that some character may be displayable on win95/win98.

Our approach is the following and it is more or less what you described. Our middle and bottom layers are completly unicode. We don't use the operating system to do string manipulation since that is not implemented on win95/98.
As soon as we go to the operating system we use defines. In WINNT the define just points to the OS directly. In win95, a conversion is made to the local DBCS system used.
BTW: we do the same with the C++ library functions to allow the software to be compiled with different C compilers. E.g. strncpy puts a 0 byte after the string on some compilers and on other compilers it does not.
0
 

Author Comment

by:tphipps
Comment Utility
Thanks Mirkwood - looks like there's no easy solution to this - because you're talking about using #defines, your implementation sounds as if you need to have 2 executable sets - one for NT and another for Win95.

I hear MSFT is using a post-link tool to modify the output executable directly to support Win95 and Unicode.
0
 
LVL 13

Expert Comment

by:Mirkwood
Comment Utility
Thanks for the points.
Yes you are right. We have seperate installation for Win95 and WinNT. We did that since testing the OS on every function would decrease the performance. I now it's only one CMP and one JNE assembly statement but still. Some interfaces are also totally different (shell extensions for example) and on NT we log to the event log and handle security different.


0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
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 pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
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.

772 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

10 Experts available now in Live!

Get 1:1 Help Now