Solved

Win32 Unicode Compatibility for Win95/98

Posted on 1998-08-29
6
313 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
ID: 1171560
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
ID: 1171561
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
ID: 1171562
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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
LVL 13

Accepted Solution

by:
Mirkwood earned 50 total points
ID: 1171563
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
ID: 1171564
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
ID: 1171565
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
C++ standard library based binary archive format 6 104
C++ question 3 71
Copy output image from TWindowsMediaPlayer 6 48
Outlook 13 45
Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
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.

820 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