🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.internationalization
Article #944

UNICODE with C++Builder

#944
From: Bala
Date: Fri, 26 Jan 2001 18:34
49 lines
2749 bytes
Can C++Builder be used to build unicode applications?
I write C++ code for a living using MC Visual C++,
and my experience with Borland C++Builder is close to none.

I have C++Builder 5 Pro with update #1.
I want to write a program that can be built for ansi or unicode
with no code changes. Let's try a simple console app.
Here is my test.cpp:

// begin test.cpp
#include <windows.h>
#include <tchar.h>
#include <stdio.h>
int _tmain( int argc, _TCHAR * argv [] )
{
    _tprintf( _T("sizeof(_TCHAR) is %d\n"), sizeof(_TCHAR) ) ;
    for ( int i = 0 ; i < argc ; ++i )
        _tprintf( _T("argv [%d]=%s\n"), i, argv[i] ) ;
    return 0 ;
}
// end test.cpp

First I build it from command line, and it works fine, I do:
bcc32 test.cpp  (to build ansi version)
or:
bcc32 -WU test.cpp  ( to build unicode version).
In both cases the code builds and works as expected.

Now I create a console app using C++Builder Console Wizard.
Building ansi version is easy, and the program works fine.
Now I want to build unicode version.
There are no unicode related options available in Project Options dialog,
so I try adding -WU to the "CFLAG1 value" in the Project Option Source xml,
but the code won't link even if I rename "_tmain" to "_main" or "main" or
"wmain".
I get "[Linker Error] Unresolved external '_main' referenced from
C:\PROGRAMS\BORLAND\CBUILDER5\LIB\C0X32.OBJ".
So I remove the -WU, and I define _UNICODE in the project settings.
Now if I rename "_tmain" to "main" the code builds,
sizeof(TCHAR) is 2, but argv strings are ansi, not unicode.
I tried creating console projects with or without VCL, same results.
I searched the book, help files, online help, and the newsgroups.
I tried cursing and I tried praying. Nothing helps :-(

So how do I create and build unicode apps in C++ Builder?

Chris B.

my real email address is "bala" at "null" dot "net"
Technical Details
Message-ID: <3a71c2e4$1_2@dnews>
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!supernews.com!isdnet!news-fra.pop.de!fu-berlin.de!news.bnb-lp.com!bornews.borland.com!dnews!12.33.142.2

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10297d,34d89127bdbc0fb9,start
X-Google-Attributes: gid10297d,public
X-Google-Thread: 103c8d,34d89127bdbc0fb9,start
X-Google-Attributes: gid103c8d,public
X-Google-ArrivalTime: 2001-01-26 10:41:23 PST
From: "Bala" <bala@nospam>
Newsgroups: borland.public.cppbuilder.internationalization,borland.public.cppbuilder.language
Subject: UNICODE with C++Builder
Date: Fri, 26 Jan 2001 13:34:24 -0500
Lines: 52
X-Newsreader: Microsoft Outlook Express 4.72.3612.1700
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3719.2500
NNTP-Posting-Host: 12.33.142.2
Message-ID: <3a71c2e4$1_2@dnews>
X-Trace: 26 Jan 2001 10:33:08 -0800, 12.33.142.2
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!supernews.com!isdnet!news-fra.pop.de!fu-berlin.de!news.bnb-lp.com!bornews.borland.com!dnews!12.33.142.2