Re: Code Page problem in SetWindowText



I've had lots of people insist that it is faster to use ANSI apps because "the strings are
shorter". They don't realize that since all of WIndows is written in Unicode, every ANSI
API has to first convert its arguments to Unicode, then call the Unicode version of the
API, so ANSI would be inherently slower.

In an experiment I ran, Unicode is on the average slightly faster than ANSI, for something
as simple as a repeated SetWindowText, although the variance of the samples is high.
joe

On Thu, 6 Sep 2007 01:37:34 +0200, "Giovanni Dicanio" <giovanni.dicanio@xxxxxxxxxx> wrote:


"Tom Serface" <tom.nospam@xxxxxxxxxxxxx> ha scritto nel messaggio
news:OIPsKEB8HHA.5212@xxxxxxxxxxxxxxxxxxxxxxx
That's a really good point. I hadn't thought of that before. So I guess
if you are moving strings in and out of controls a lot there could even be
a performance improvement using Unicode.

Hi Tom,

I completely agree with this analysis by David, at least on the (real)
operating systems like Win2K/XP/Vista, that are Unicode-native.
(Win9x "toys" are a different thing, maybe there ANSI is faster than
Unicode, because they are ANSI/MBCS-native, but the Win9x family is not
interesting for me.)

G

Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.



Relevant Pages

  • Re: Skipws
    ... I have tested skipws works for both ANSI and UNICODE version strings (i.e. ... char and wchar_t). ...
    (microsoft.public.vc.language)
  • Re: Delphi 2009 - CG tip everything on ( only ) Unicode ?
    ... The Unicode versions of the Win32 API calls are faster then the ANSI ... file and folder names are in Unicode. ...
    (borland.public.delphi.non-technical)
  • Re: Suggested Alternative Unicode Implementation (for Rudy+ miscothers)
    ... No, not quite, because the VCL is still Unicode so your application will ... to continue to safely run in an "ANSI world" ... This compiles perfectly fine, but maybe it doesn't work correctly for ... "choose" the A/W API, you get the API appropriate to the sype of the ...
    (borland.public.delphi.non-technical)
  • Re: Serial Port : error in opening
    ... >> must be UNICODE, not ANSI. ... If you're reading existing ANSI files, ... >> you can choose to keep the strings as ANSI internally. ... >> bom windows ce ...
    (microsoft.public.windowsce.embedded.vc)
  • 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)