By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,224 Members | 1,233 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,224 IT Pros & Developers. It's quick & easy.

unicode vs. ansi strings in WriteFile

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.