Solved

Win32 Unicode Compatibility for Win95/98

Posted on 1998-08-29
6
314 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
[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
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
Technology Partners: 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!

 
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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

Suggested Solutions

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…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
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.

739 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