473,786 Members | 2,744 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

What to prefer - TCHAR arrays, std::string or std::wstring ?

Hi

While developing any software, developer need to think about it's
possible enhancement for international usage and considering UNICODE.

I have read many nice articles/items in advanced C++ books (Effective
C++, More Effective C++, Exceptional C++, More Exceptional C++, C++
FAQs, Addison Wesley 2nd Edition)

Authors of these books have not considered UNICODE. So many of their
suggestions/guidelines confuse developers regarding what to use for
character-string members of class (considering exception-safety,
reusability and maintenance of code).

Many books have stated that:
Instead of using character arrays, always prefer using std::string.

My Questions is:

While developing generic Win32 app using C++ for Windows
(98/NT/2000/2003/XP), considering unicode for Windows NT/2000/2003/XP,
What to prefer - TCHAR arrays, std::string or std::wstring
for character-string members (name, address, city, state, country etc.)

of classes like Address, Customer, Vendor, Employee ?

What to prefer - TCHAR arrays, std::string or std::wstring ?

I truly appreciate any help or guideline.
Anand

Aug 2 '06
14 12198
Bo Persson wrote:
Windows 95, 98, and NT are officially unsupported both as OSs and as
targets for the present compiler. All currently supported Windows versions
use wchar_t internally. New applications could do that as well.
Nice to know, but I use "Win95s" to refer to the lineage, up to ME, and
WinNTs for versions up to Win2005 or whatever.
Using TCHAR to optionally compile a new application for a dead OS doesn't
seem very useful to me. :-)
The OP seems to have a requirements bottleneck. Sometimes a client will
over-specify everything, hoping to keep their options open. Narrow
requirements and clean code will do that better than guessing that the
program must someday port to a Win95-derived platform.

Is WinME officially dead?
Except that these are as dead as their OSs. Can't be distributed after
their end-of-life.
You mean MS makes packaging an unsupported DLL illegal? They retract its
license or something? Don't they know the 17th Rule of Acquisition is "A
contract is a contract"?

Regardless, if the client actually needs to target the home market, they
must start with MS's official definition of that market.

Turning on UNICODE will make all OS strings wide, and will turn on UTF-16.
Hence, go with std::wstring, hard-coded, everywhere.

--
Phlip
http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!!!
Aug 3 '06 #11

"Phlip" <ph******@yahoo .comskrev i meddelandet
news:EX******** ********@newssv r13.news.prodig y.com...
Bo Persson wrote:
>Windows 95, 98, and NT are officially unsupported both as OSs and
as targets for the present compiler. All currently supported
Windows versions use wchar_t internally. New applications could do
that as well.

Nice to know, but I use "Win95s" to refer to the lineage, up to ME,
and WinNTs for versions up to Win2005 or whatever.
>Using TCHAR to optionally compile a new application for a dead OS
doesn't seem very useful to me. :-)

The OP seems to have a requirements bottleneck. Sometimes a client
will over-specify everything, hoping to keep their options open.
Narrow requirements and clean code will do that better than guessing
that the program must someday port to a Win95-derived platform.

Is WinME officially dead?
It is still supported I guess, but it never worked very well. Was sort
of a downgrade from Windows 98 - nothing much new, just more unstable.
:-)
>
>Except that these are as dead as their OSs. Can't be distributed
after their end-of-life.

You mean MS makes packaging an unsupported DLL illegal? They retract
its license or something? Don't they know the 17th Rule of
Acquisition is "A contract is a contract"?
From what I know, MS has removed it from their servers so you cannot
get it legitimately anymore. If you already use it and continue to
distribute it, they will probably not sue. If you have a problem
though, what happens?
>
Regardless, if the client actually needs to target the home market,
they must start with MS's official definition of that market.

Turning on UNICODE will make all OS strings wide, and will turn on
UTF-16. Hence, go with std::wstring, hard-coded, everywhere.
Right.
Bo Persson
Aug 3 '06 #12
Phlip wrote:
>
Is WinME officially dead?

WinME was officially dead upon release. :-)
Aug 3 '06 #13
Bo Persson wrote:
>Turning on UNICODE will make all OS strings wide, and will turn on
UTF-16. Hence, go with std::wstring, hard-coded, everywhere.

Right.
Then, per my lecture on requirements, neither compile for nor use any 8-bit
mode, or std::string. Never leave a "flavor" of a program that's full of
bugs and nasty surprises, expecting that it "might be useful someday".

--
Phlip
http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!!!
Aug 3 '06 #14
red floyd wrote:
WinME was officially dead upon release. :-)
Why didn't they just call it WinY2K Bug?

;-)

--
Phlip
http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!!!
Aug 3 '06 #15

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

Similar topics

1
12287
by: red floyd | last post by:
I have a an app that I'm writing which uses char and std::string. I'm using a library which expects wchar_t arrays. Is there a standard way to convert between std::string and std::wstring, or do I need to use something like std::transform()? Thanks
12
28206
by: Flzw | last post by:
How to convert a std::string to a WCHAR* ? is there any methods or something ? I can't find. Thanks
3
5510
by: Lars Nielsen | last post by:
Hey there I have a win32 application written i c++. I have a std::vector of std::string's i will fill with filenames. typedef vector<std::string> strvector; strvector vFiles; WIN32_FIND_DATA fd;
9
22564
by: vsgdp | last post by:
Hi, Is there a unicode equivalent to std::string?
5
48702
by: Karthik | last post by:
Hello, How can I convert a BSTR data type to std::string??? Thanks a much! Karthik
37
3817
by: jortizclaver | last post by:
Hi, I'm about to develop a new framework for my corporative applications and my first decision point is what kind of strings to use: std::string or classical C char*. Performance in my system is quite importante - it's not a realtime system, but almost - and I concern about std::string performance in terms of speed. No doubt to use std implementation is a lot easier but I can't sacrifice speed.
10
10140
by: Jeffrey Walton | last post by:
Hi All, I've done a little homework (I've read responses to similar from P.J. Plauger and Dietmar Kuehl), and wanted to verify with the Group. Below is what I am performing (Stroustrup's Appendix D recommendation won't compile in Microsoft VC++ 6.0). My question is in reference to MultiByte Character Sets. Will this code perform as expected? I understand every problem has a simple and elegant solution that is wrong.
3
3703
by: Angus | last post by:
I can see how to get a char* but is it possible to get a wide char - eg wchar_t?
10
8275
bajajv
by: bajajv | last post by:
Hi, I was trying to implement CString with std::string and std::wstring. class CString { public: std::string str; CString() {str = "ABCD";} //this works }: class CString {
0
9497
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10363
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10164
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10110
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9962
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7515
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6748
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5534
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.