473,499 Members | 1,903 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

unicode vs. ansi strings in WriteFile

Hi,

I am extending an existing MFC app to use Unicode (for a
Japanese version of the interface elements). The app's
purpose is to control a peripheral device through the
serial port, and the device only understands ansi strings
(in fact, I synthesize a character stream and send it as
though it was typed into a terminal). The problem seems to
be that the VC++ 6 linker insists that if I use the
#define UNICODE and _UNICODE preprocessor directives and
the wWinMainCRTStartup entry point, all my calls to
ReadFile and WriteFile will happen in Unicode! In other
words, my Unicode app will always send Unicode text
through the serial port, which screws up communications
with the device. There must be a way of forcing the
Read/WriteFile functions to call their ANSI versions
instead of the Unicode ones, or line printers would go
nuts, right? How do I link Read/WriteFile to the ANSI
versions?
Nov 16 '05 #1
1 4427
Paul wrote:
Hi,

I am extending an existing MFC app to use Unicode (for a
Japanese version of the interface elements). The app's
purpose is to control a peripheral device through the
serial port, and the device only understands ansi strings
(in fact, I synthesize a character stream and send it as
though it was typed into a terminal). The problem seems to
be that the VC++ 6 linker insists that if I use the
#define UNICODE and _UNICODE preprocessor directives and
the wWinMainCRTStartup entry point, all my calls to
ReadFile and WriteFile will happen in Unicode! In other
words, my Unicode app will always send Unicode text
through the serial port, which screws up communications
with the device. There must be a way of forcing the
Read/WriteFile functions to call their ANSI versions
instead of the Unicode ones, or line printers would go
nuts, right? How do I link Read/WriteFile to the ANSI
versions?


That's not your problem (and I don't know exactly what is your problem).

ReadFile and WriteFile deal solely in bytes - they know nothing of
characters, character sets, ASCII or Unicode. In short - there is no
"Unicode" version of these APIs.

If you can show some code that you're using to interact with the serial
port, I'm sure someone can spot where you're getting a "helpful" unicode
conversion that you're not aware of.

-cd
Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
26562
by: ..... | last post by:
I have an established program that I am changing to allow users to select one of eight languages and have all the label captions change accordingly. I have no problems with English, French, Dutch,...
2
1802
by: Grace | last post by:
Dear Sir, By default, an application build on .net framework 1.0 or 1.1 is it a unicode application?? and If i use VS.net 2003 (VC# or VC++) by defualt is it a unicode or ANSI appliation?
5
2067
by: Tamir Khason | last post by:
I have a program will really big embedded text resources. Because of internationalization I have to save the embedded text in UTF-8, but it more then triple bigger then the original file. The last...
18
34067
by: Ger | last post by:
I have not been able to find a simple, straight forward Unicode to ASCII string conversion function in VB.Net. Is that because such a function does not exists or do I overlook it? I found...
2
3161
by: Mike Labosh | last post by:
I need to determine if a string contains double-byte (unicode) characters. In SQL, it was easy. Cast it from NVARCHAR to VARCHAR and back again, and see if it got lossage. But in VB.NET, all...
40
3146
by: apprentice | last post by:
Hello, I'm writing an class library that I imagine people from different countries might be interested in using, so I'm considering what needs to be provided to support foreign languages,...
5
1730
by: Norman Diamond | last post by:
Here are two complete lines of output from Visual Studio 2005: 1>$B%W%m%8%'%/%H=PNO$K(B Authenticode $B=pL>$7$F$$$^$9(B... 1>Successfully signed: c:\T The first line means roughly: Doing...
18
620
by: Chameleon | last post by:
I am trying to #define this: #ifdef UNICODE_STRINGS #define UC16 L typedef wstring String; #else #define UC16 typedef string String; #endif ....
6
18028
by: msdnuniv | last post by:
Hello everybody, since days i try to convert Unicode-Strings in VB.NET to ANSI which should be processable in VB6 and converted to unicode again. It should be possible with any codepage, e.g....
0
7134
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7012
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7180
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6901
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
4920
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3105
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3101
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1429
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
307
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.