Solved

Win32 Unicode Compatibility for Win95/98

Posted on 1998-08-29
6
311 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
why "." vs "->" 23 119
Socket Programming (Unix) 8 118
c++ getting the first 10 characters of a char* string 11 90
basic hardware to learn oop advanced design patterns 3 88
Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

914 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

12 Experts available now in Live!

Get 1:1 Help Now