Re: C++ help needed!(My own solution)

Tech-Archive recommends: Speed Up your PC by fixing your registry

From: Alexander Grigoriev (alegr_at_earthlink.net)
Date: 10/23/04


Date: Fri, 22 Oct 2004 21:23:03 -0700

There are different ways to use UNICODE in ANSI build.

First, you know that UNICODE data is declared as WCHAR in Windows programs.
You can use wchar_t now, though. If you want to pass UNICODE string to a
function, but have TCHAR or CString source, you can use T2W macro (see "ATL
and MFC String Conversion Macros" topic). With VC7, you can use CStringW:

void f(LPCTSTR s)
{
FunctionW(CStringW(s));
}

This will create a temporary UNICODE CString, applying conversion, if
necessary. CT2W macro does about the same (but skips a temporary for UNICODE
build).

You don't quite understand what "scalable" means. LPCTSTR type definitely
doesn't break when the program workload gets greater or the program gets
larger.

"Sergey Kochkarev" <kochkarev@pisem.net> wrote in message
news:c882495.0410212311.1ac08455@posting.google.com...
> "Alexander Grigoriev" <alegr@earthlink.net> wrote in message
> news:<uX$uFF#tEHA.2000@TK2MSFTNGP14.phx.gbl>...
>
> Yeah, you are right - unless someone wants to use unicode and ANSI in
> the same program. Wanna example - here you are. Some newly invented
> interfaces in XP accept unicode strings only - but my program is ANSI
> and will never be unicode. So parts of the program use ANSI, others
> use unicode - to use LPCTSRT would be tricky. Espscially if we have
> good old standard char and wchar. LPCTSTR is just not scalable, it is
> worthless to use it in programs bigger than Hello world.



Relevant Pages

  • Re: Call C DLL from VB.net-problem..array gains 4 bytes!
    ... No, Unicode strings don't, by definition, have a header with the size. ... you're writing code in C++, for example, the only difference between an ANSI ... which take an array of bytes. ... > Remember the DLL declaration... ...
    (microsoft.public.windowsce.app.development)
  • Re: A (mild-mannered) defense of RosAsm Rocks !!!
    ... All functions that have a Unicode ... and ANSI implementation are Unicode first, ... this API is not available in Win9x without the ... Oh by the way the Coward is the asshole that wrote the peice of garbage ...
    (alt.lang.asm)
  • Re: Delphi 2009/2010 ohne Unicode?
    ... Wenn Eingabe und Ausgabe ANSI ist, ... dann möchte ich in Bauch nicht mit Unicode ... arbeiten da zum einen die Eingangskonvertierung ... Zeichen in UTF-16 keine Surrogate-Pairs benötigen. ...
    (de.comp.lang.delphi.misc)
  • Re: Error 52 Bad file name or number on file read
    ... Sorry Nick but if you're ending up with a mixture of ANSI and Unicode data ... Private Type FILETIME ... Public Function StripNulls(sText As String) As String ...
    (microsoft.public.vb.general.discussion)
  • RE: Encoding query - Ansi
    ... Saving as text won't remove the control characters. ... produced via an OLE, they are unicode files. ... way i can do this is to resave the text files with ansi encoding. ...
    (microsoft.public.excel.programming)