-
August 22nd, 2015, 05:21 PM
#1
VC++6.0, Unicode, and ANSI strings
I have a VC++ 6.0 project that I'm thinking about rebuilding in Unicode. The bigget problem is that the data that I have to processes is 8-bit binary data that sometimes contains strings (e.g. "-12345X") that I have to detect.
I would like to have a class, something like an equivalent CStringA, that I can use on the 8-bit data when compiled with UNICODE/_UNICODE defined. I don't want to reinvent the wheel if someone has already done the heavy lifting. If not then I was thinking of wrapping the string function (i.e. strcat(), strcmp(), strcpy(), etc.) in a class.
Actually, I'm not sure it is worth the effort to rebuild in Unicode.
Anybody know of something I can beg, borrow, or steal?
-
August 23rd, 2015, 05:41 AM
#2
Re: VC++6.0, Unicode, and ANSI strings
In case it works in ANSI for you, why bother to rebuild? Rebuild may make sense when you wish to move to a contemporary compiler, or multi-cultural /lingual support is required. If none of those is the case, why bother to rebuild?
Besides, having a project set up for Unicode by no means implies your strings cannot be ANSI when required. You can combine those wherever you want alright.
Best regards,
Igor
-
August 23rd, 2015, 11:15 AM
#3
Re: VC++6.0, Unicode, and ANSI strings
Hi Igor,
I should have provided more information in my original post. In fact, my thoughts were, and are, about moving to a new compiler AND supporting multi-language. Although, at this time, I have no idea what multi-language support entails - I'll worry about that later.
The problem is that CStrings are ANSI or Unicode depending whether UNICODE/_UNICODE are defined. So I'm left with the problem needing ANSI strings for the data and using Unicode CStrings everywhere else.
I just don't want to create my own wrapper-class if something already exists that I can use.
Thanks,
Mike
-
August 23rd, 2015, 06:11 PM
#4
Re: VC++6.0, Unicode, and ANSI strings
Here's what I would recommend:
Compile your program for UNICODE
All strings and string related api calls are in Unicode (and data passed within your program is Unicode)
Convert data that needs to be ansi when it enters and leaves your program
Provide a conversion layer so the conversions get done in one place (makes it easier to debug)
Make use of the ATL/MFC String Conversion Macros
-
August 24th, 2015, 08:09 AM
#5
Re: VC++6.0, Unicode, and ANSI strings
You keep talking about CString while there is no such a class. There are CStringA and CStringW. Unicode-aware macros do you a favor and translate CString to CStringW, but for strict ANSI data you always can use CStringA specifying the one explicitly. I still don't get what sort of "your own wrapper class" you would need other than standard string classes.
Best regards,
Igor
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|