B
Bill Davy
Just curious. I often define them myself.
Bill
Bill
Bill said:Xxxx <=> char
wXxxx <=> wchar
tXxxx <=> TCHAR
By analogy with:
int _tmain(int argc, _TCHAR* argv[])
{
if ( argc < 3 )
{
tostringstream s;
s << argv[0] << _T(": need priority and command arguments at least\n");
It's tedious getting hex numbers when you write "cerr < argv[0]"
Bill said:Xxxx <=> char
wXxxx <=> wchar
tXxxx <=> TCHAR
By analogy with:
int _tmain(int argc, _TCHAR* argv[])
{
if ( argc < 3 )
{
tostringstream s;
s << argv[0] << _T(": need priority and command arguments at least\n");
It's tedious getting hex numbers when you write "cerr < argv[0]"
There's no TCHAR or _tmain in C++, it's a Microsoft specific extension.
It's meant to simplify the migration from Ansi/ASCII to Unicode for
Application that also must run on older Windows version without Unicode
support.
You would have to ask on a Microsoft or VC++ related forum, why they
didn't also provide typedefs for tstring, tcerr etc.
The easiest solution is to use Unicode (wchar_t) or non-Unicode (char)
exclusively. If a program should support Unicode, use wchar_t, otherwide
use char.
"Thomas J. Gritzan" <[email protected]> kirjutas:
Or use char and UTF-8 exclusively, to support Unicode. UTF-8
seems to be the preferred encoding in network and XML world,
as well as on Linux desktops. The drawback is that on Windows,
you might have to translate to UTF-16 (that's what Windows is
using) and back often.
Using wchar_t does not guarantee Unicode automatically, as it
might be mapped to UTF-16 on Windows and to UTF-32 on other
platforms, which are totally different things and need
different approach.
If you are coding for Windows only, then the wise thing (which
does not mean I'm actually recommending it!) would be to use
their TCHAR and friends, they most probably will remain
back-compatible to some extent.
James said:[...]The problem is that they promote a lie; the give theIf you are coding for Windows only, then the wise thing
(which does not mean I'm actually recommending it!) would
be to use their TCHAR and friends, they most probably will
remain back-compatible to some extent.
impression that you can easily switch to and from Unicode,
just by changing a typedef.
I've done this, although not using 'TCHAR', and across
several platforms. What makes this impossible IYO?
James said:The fact that the way the encodings work is different.James Kanze wrote:
[...]
If you are coding for Windows only, then the wise thing
(which does not mean I'm actually recommending it!) would
be to use their TCHAR and friends, they most probably
will remain back-compatible to some extent.
The problem is that they promote a lie; the give the
impression that you can easily switch to and from Unicode,
just by changing a typedef.
I've done this, although not using 'TCHAR', and across
several platforms. What makes this impossible IYO?
Um, I guess the confusion stems from your "just by changing
a typedef". Of course, there's a lot more required than just
changing a typedef, but it can be done so that just changing
a typedef does all this. I suppose you referred to the former
(it needs more), while I referred to the latter (it can be
done so that changing a typedef does everything that needs to
be done).
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.