473,396 Members | 2,020 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

convert a prorams from ASCII to UNICODE

I have a c program that uses the "A" version of API files.

Since it runs on XP I'd guess it would be better if it used the "W"
versions.
Why is it using the "A" version. I looked in properties and can't find where
it is instructed to use the "A"

What do I have to do to get it to use the "W" versions and more importantly,
what must I change in my program.

For example, all char definitions become what??

Thanks in advance
Jan 6 '07 #1
8 3383
You must define UNICODE (or _UNICODE) and recompile your program (and, of course,
use generic types like TCHAR (or _TCHAR) instead of char or wchar_t . Also you always
must use strings with _T or _TEXT macros: use _T("string") instead of "string").
Take a look to tchar.h, winnt.h and winuser.h to get an idea how all of this works.

http://msdn2.microsoft.com/en-us/lib...eb(VS.80).aspx
Regards

--
Cholo Lennon
Bs.As.
ARG

" Frank" <fr***@a-znet.comescribió en el mensaje
news:uf**************@TK2MSFTNGP03.phx.gbl...
>I have a c program that uses the "A" version of API files.

Since it runs on XP I'd guess it would be better if it used the "W" versions.
Why is it using the "A" version. I looked in properties and can't find where it is
instructed to use the "A"

What do I have to do to get it to use the "W" versions and more importantly, what
must I change in my program.

For example, all char definitions become what??

Thanks in advance

Jan 6 '07 #2
The doc you sited below is very helpful.

Leaves me with one question. It says:
Do not use the str family of functions with Unicode strings, which are
likely to contain embedded null bytes.

What is the family of functions I'm suppose to use?

Thanks for all the help
"Cholo Lennon" <ch*********@hotmail.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
You must define UNICODE (or _UNICODE) and recompile your program (and, of
course, use generic types like TCHAR (or _TCHAR) instead of char or
wchar_t . Also you always must use strings with _T or _TEXT macros: use
_T("string") instead of "string").
Take a look to tchar.h, winnt.h and winuser.h to get an idea how all of
this works.

http://msdn2.microsoft.com/en-us/lib...eb(VS.80).aspx
Regards

--
Cholo Lennon
Bs.As.
ARG

" Frank" <fr***@a-znet.comescribió en el mensaje
news:uf**************@TK2MSFTNGP03.phx.gbl...
>>I have a c program that uses the "A" version of API files.

Since it runs on XP I'd guess it would be better if it used the "W"
versions.
Why is it using the "A" version. I looked in properties and can't find
where it is instructed to use the "A"

What do I have to do to get it to use the "W" versions and more
importantly, what must I change in my program.

For example, all char definitions become what??

Thanks in advance


Jan 7 '07 #3
Leaves me with one question. It says:
Do not use the str family of functions with Unicode strings, which are likely to
contain embedded null bytes.

What is the family of functions I'm suppose to use?
Unicode strings can contain null characters inside(*) so you must not use the str
familiy functions (strcpy, strlen, etc). You must use the tcs family functions
(tcscpy, tsclen, etc). You can avoid this double thinking :-p if you use the _tsc
family macros for ascii/unicode compatibility (_tcscpy, _tcslen, etc).

* because each character occupies 2 bytes and some character mapping only needs 1
byte (the remaining one is 0, NULL). The end terminator in unicode strings is a
double NULL.

Another useful article:
http://www.codeproject.com/cpp/unicode.asp
Regards

--
Cholo Lennon
Bs.As.
ARG


" Frank" <fr***@a-znet.comescribió en el mensaje
news:%2****************@TK2MSFTNGP03.phx.gbl...
The doc you sited below is very helpful.

Leaves me with one question. It says:
Do not use the str family of functions with Unicode strings, which are likely to
contain embedded null bytes.

What is the family of functions I'm suppose to use?

Thanks for all the help
"Cholo Lennon" <ch*********@hotmail.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
>You must define UNICODE (or _UNICODE) and recompile your program (and, of course,
use generic types like TCHAR (or _TCHAR) instead of char or wchar_t . Also you
always must use strings with _T or _TEXT macros: use _T("string") instead of
"string").
Take a look to tchar.h, winnt.h and winuser.h to get an idea how all of this
works.

http://msdn2.microsoft.com/en-us/lib...eb(VS.80).aspx
Regards

--
Cholo Lennon
Bs.As.
ARG

" Frank" <fr***@a-znet.comescribió en el mensaje
news:uf**************@TK2MSFTNGP03.phx.gbl...
>>>I have a c program that uses the "A" version of API files.

Since it runs on XP I'd guess it would be better if it used the "W" versions.
Why is it using the "A" version. I looked in properties and can't find where it
is instructed to use the "A"

What do I have to do to get it to use the "W" versions and more importantly, what
must I change in my program.

For example, all char definitions become what??

Thanks in advance



Jan 7 '07 #4
Hi Frank!
I have a c program that uses the "A" version of API files.
Since it runs on XP I'd guess it would be better if it used the "W"
versions.
For an "step-throu" see:
Converting a project to Unicode: Part 1-9
http://blogs.msdn.com/michkap/archiv...5/1413001.aspx

--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/
Jan 7 '07 #5
Why is it using the "A" version. I looked in properties and can't find
where it is instructed to use the "A"
This is whay you end up with "A" versions, although you don't explicitely use
them: http://www.mihai-nita.net/20050306b.shtml

What do I have to do to get it to use the "W" versions and more
importantly, what must I change in my program.

For example, all char definitions become what??
Add Unicode configurations to your project
(for instance ReleaseU derived from Release and and DebugU derived from
Debug). In order to build Unicode versions you need to define *both*
UNICODE and _UNICODE, and to change the entry point.
You have to exeplicitely do this in older VS6 and older, but you have
one single option in newer versions:
http://www.mihai-nita.net/20060723a.shtml

Then start changing all the data types to generic data types:
char to TCHAR, wrap strings in _T("...") (or TEXT("..."), or _TEXT("..."),
is the same thing). Change all C api to generic strcpy to _tcscpy, etc.
(in the MSDN doc each C function has a section called "Generic-Text Routine
Mappings", use the stuff in the "TCHAR.H routine" column).

Helpful links:
- Then take a look at this, for the high-level steps:
http://www.microsoft.com/globaldev/g...g_unicode.mspx
- Then see "Converting a project to Unicode: Part 1-9" (Jochen's post),
where Michael Kaplan takes an ANSI project and migrates it to Unicode,
explaining what he's doing and why.
- Then Cholo's link is good to fill in the gaps and API details.
--
Mihai Nita [Microsoft MVP, Windows - SDK]
http://www.mihai-nita.net
------------------------------------------
Replace _year_ with _ to get the real email
Jan 7 '07 #6
Another good site
Thanks again

"Cholo Lennon" <ch*********@hotmail.comwrote in message
news:uk**************@TK2MSFTNGP02.phx.gbl...
>Leaves me with one question. It says:
Do not use the str family of functions with Unicode strings, which are
likely to contain embedded null bytes.

What is the family of functions I'm suppose to use?

Unicode strings can contain null characters inside(*) so you must not use
the str familiy functions (strcpy, strlen, etc). You must use the tcs
family functions (tcscpy, tsclen, etc). You can avoid this double thinking
:-p if you use the _tsc family macros for ascii/unicode compatibility
(_tcscpy, _tcslen, etc).

* because each character occupies 2 bytes and some character mapping only
needs 1 byte (the remaining one is 0, NULL). The end terminator in unicode
strings is a double NULL.

Another useful article:
http://www.codeproject.com/cpp/unicode.asp
Regards

--
Cholo Lennon
Bs.As.
ARG


" Frank" <fr***@a-znet.comescribió en el mensaje
news:%2****************@TK2MSFTNGP03.phx.gbl...
>The doc you sited below is very helpful.

Leaves me with one question. It says:
Do not use the str family of functions with Unicode strings, which are
likely to contain embedded null bytes.

What is the family of functions I'm suppose to use?

Thanks for all the help
"Cholo Lennon" <ch*********@hotmail.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
>>You must define UNICODE (or _UNICODE) and recompile your program (and,
of course, use generic types like TCHAR (or _TCHAR) instead of char or
wchar_t . Also you always must use strings with _T or _TEXT macros: use
_T("string") instead of "string").
Take a look to tchar.h, winnt.h and winuser.h to get an idea how all of
this works.

http://msdn2.microsoft.com/en-us/lib...eb(VS.80).aspx
Regards

--
Cholo Lennon
Bs.As.
ARG

" Frank" <fr***@a-znet.comescribió en el mensaje
news:uf**************@TK2MSFTNGP03.phx.gbl...
I have a c program that uses the "A" version of API files.

Since it runs on XP I'd guess it would be better if it used the "W"
versions.
Why is it using the "A" version. I looked in properties and can't find
where it is instructed to use the "A"

What do I have to do to get it to use the "W" versions and more
importantly, what must I change in my program.

For example, all char definitions become what??

Thanks in advance



Jan 7 '07 #7
Lots of good info

thanks

"Jochen Kalmbach [MVP]" <no********************@holzma.dewrote in message
news:OH**************@TK2MSFTNGP06.phx.gbl...
Hi Frank!
>I have a c program that uses the "A" version of API files.
Since it runs on XP I'd guess it would be better if it used the "W"
versions.

For an "step-throu" see:
Converting a project to Unicode: Part 1-9
http://blogs.msdn.com/michkap/archiv...5/1413001.aspx

--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/

Jan 7 '07 #8
Thanks a lot

"Mihai N." <nm**************@yahoo.comwrote in message
news:Xn*******************@207.46.248.16...
>Why is it using the "A" version. I looked in properties and can't find
where it is instructed to use the "A"
This is whay you end up with "A" versions, although you don't explicitely
use
them: http://www.mihai-nita.net/20050306b.shtml

>What do I have to do to get it to use the "W" versions and more
importantly, what must I change in my program.

For example, all char definitions become what??

Add Unicode configurations to your project
(for instance ReleaseU derived from Release and and DebugU derived from
Debug). In order to build Unicode versions you need to define *both*
UNICODE and _UNICODE, and to change the entry point.
You have to exeplicitely do this in older VS6 and older, but you have
one single option in newer versions:
http://www.mihai-nita.net/20060723a.shtml

Then start changing all the data types to generic data types:
char to TCHAR, wrap strings in _T("...") (or TEXT("..."), or _TEXT("..."),
is the same thing). Change all C api to generic strcpy to _tcscpy, etc.
(in the MSDN doc each C function has a section called "Generic-Text
Routine
Mappings", use the stuff in the "TCHAR.H routine" column).

Helpful links:
- Then take a look at this, for the high-level steps:
http://www.microsoft.com/globaldev/g...g_unicode.mspx
- Then see "Converting a project to Unicode: Part 1-9" (Jochen's post),
where Michael Kaplan takes an ANSI project and migrates it to Unicode,
explaining what he's doing and why.
- Then Cholo's link is good to fill in the gaps and API details.
--
Mihai Nita [Microsoft MVP, Windows - SDK]
http://www.mihai-nita.net
------------------------------------------
Replace _year_ with _ to get the real email

Jan 7 '07 #9

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

Similar topics

6
by: Markus Hämmerli | last post by:
I ' ll tra to convert a Cstring to char* without success. I working in a Unicode enabled environment this is working in Unicode CString source = _T("TestString"); TCHAR *szSource =...
1
by: Adam | last post by:
Hello, I'm trying to decifer the data in the table that stores the data in the binary format. All numbers are placed in varbinary fields. All I know is the MS SQL 2000 database useing collation...
2
by: z. f. | last post by:
Hi, i need to convert a unicode string to ascii string (in order to put it in HTML page url ) right now the string gets to the page, but when the url clicked (with the unicode string in a...
8
by: davihigh | last post by:
My Friends: I am using std::ofstream (as well as ifstream), I hope that when i wrote in some std::string(...) with locale, ofstream can convert to UTF-8 encoding and save file to disk. So does...
4
by: Dirk Hagemann | last post by:
Hi! When I receive data from Microsoft Active Directory it is an "ad_object" and has the type unicode. When I try to convert it to a string I get this error: UnicodeEncodeError: 'ascii' codec...
8
by: csanjith | last post by:
Hi, i have a situaion where i need to convert the characters entered in an text field to upper case using C. The configuration id utf8 environment in which user can enter any character (single ,...
1
by: recover | last post by:
#include <xxx> int main() { const wchar* pwcHello=L"hello"; char* pcHello; xxxxxx //do something using stl cout<<pcHello<<endl; } =============out===========
0
by: M.-A. Lemburg | last post by:
On 2008-07-01 20:31, Peter Bulychev wrote: You could write a codec which translates Unicode into a ASCII lookalike characters, but AFAIK there is no standard for doing this. I guess the best...
19
by: est | last post by:
From python manual str( ) Return a string containing a nicely printable representation of an object. For strings, this returns the string itself. The difference with repr(object) is that...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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
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,...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.