Re: Code Page problem in SetWindowText

Tech-Archive recommends: Fix windows errors by optimizing your registry



I probably described the problem wrong.

A better description might be that there are Asc and Chr function calls
throughout the code, not duplication of algorithms throughout the code.
Those Asc and Chr function calls cause problems when a Chinese code page is
set as the default language. Each time that we hit a hex value with no
corresponding Ascii value in the code page, we get the "?' returned.
Needless to say, that causes some significant discrepences when
encrypting/decrypting a string of data.

I figured that I was going to have to move to byte arrays, but thought I'd
take a stab in the dark at a solution that would allow me to just overrid the
code page.


"Joseph M. Newcomer" wrote:

Encryption should be independent of locale, so I'm curious how there could be a problem.
In addition, "algorithms peppered throughout" the code suggests that there are deeper
architectural problems, since in most cases there is exactly ONE instance of the
algorithm, in ONE place. They are probably written in terms of char*, which assumes a
NUL-terminated 8-bit character string, which makes them instantly obsolete. They should
be written in terms of counted byte strings, not character strings.
joe

On Fri, 7 Sep 2007 09:46:06 -0700, PackAddict <PackAddict@xxxxxxxxxxxxxxxxxxxxxxxxx>
wrote:

I'm struggling with a similar issue. I have encryption algorithms peppered
throught some legacy code (some written in VB3). They don't work when a
regional code page that is Unicode based is selected.

Is there a way to override the system regional code page setting to force a
VB 6 application to use "English (United States)"?


"Tom Serface" wrote:

Yeah, I hadn't thought of that angle. Sometimes I get all focused on local
heap memory and forget about all the automatic stuff happening behind the
scenes. I can say with a degree of certainty that going to Unicode has
worked for us over the last few years. There was some initial shock in the
transition, but it wasn't difficult to work through. Now we just do
everything Unicode so it makes life easier all around.

Tom

"Giovanni Dicanio" <giovanni.dicanio@xxxxxxxxxx> wrote in message
news:eJ81NXB8HHA.3624@xxxxxxxxxxxxxxxxxxxxxxx

"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: Code Page problem in SetWindowText
    ... Since VB3 is an antique, I'm not at all sure what it was doing with its functions. ... "algorithms peppered throughout" the code suggests that there are deeper ... be written in terms of counted byte strings, ... I can say with a degree of certainty that going to Unicode has ...
    (microsoft.public.vc.mfc)
  • Re: tuples, index method, Pythons design
    ... Then this algorithm is no longer guaranteed to work with strings. ... It never worked correctly on unicode strings anyway (which becomes the ... But I've thought of those algorithms ... and unicode strings are still just sequences of code points. ...
    (comp.lang.python)
  • Re: How to check variables for uniqueness ?
    ... characters is the sequence SS. ... is simply capitalizing strings. ... The fact that case mapping in English /is/ simple is neither here not ... That is a fair criticism of the Unicode position. ...
    (comp.lang.java.programmer)
  • Re: Dangerous behavior of CString
    ... If I'm reading a data file or serial port or something, if the raw data are multibyte but the compilation is Unicode or vice-versa, then sometimes the converting constructors in CString are convenient. ... I did not actually write code like this; in fact I was pretty careful always to use the _T macro with any literal strings. ... But it does the conversion using the current 8-bit code page, which is not what I want. ...
    (microsoft.public.vc.mfc)
  • Re: Help please
    ... i would like to provide "CSimString" class code because the settings ... I agree with Tom that first step is project clean and rebuild all. ... with a Unicode string, ... Consider that VS2005 strings are Unicode by default, ...
    (microsoft.public.vc.mfc)