----- Original Message ----- 
From: "Peter Van Hove" <pe...@smart-projects.net>
To: <twsocket@elists.org>
Sent: Sunday, October 25, 2009 12:21 PM
Subject: [twsocket] error "Invalid code page" (Peter Van Hove)


>>> But I did a search in the files for "Invalid code page" and I
>>> couldn't find anything ... so I fear I'm barking up the wrong tree
>>> anyway.
>>>
>>> But then ... if anybody has an idea, let me know.
>>
>> I don't believe it's in ICS.
>> Anyway the easiest way to catch this bug reliable was to include, for
>> example, MadExcept into your project that the generates a bug report
>> including a nice stack trace with source code line numbers.
>> MadExcept comes with its own email clients so the user is able
>> to send you the bugreport with a single mouse click.
> 
> Thanks for the MadExcept tip Arno, I will check it out.
> 
> Meanwhile I was searching the net for this errror and I came accross a post:
> https://forums.codegear.com/thread.jspa?threadID=9290
> 
> Where it said:
> "The error is actually coming from Windows, not Delphi,
> when TEncoding's constructor passes $FFFF to the Win32 API GetCPInfo()
> function and it fails."

Passing an invalid codepage to GetCPInfo will let the function fail
with return ERROR_INVALID_PARAMETER, the exception is actually
raised in the constructor of the TMBCSEncoding class, ICS does not use 
TEncoding but uses the WinAPI directly for custom string convertions.
If there ever was an invalid codepage passed to the WinAPI you would 
get back some garbage string instead of an exception.

Any application that includes SysUtils will initialize two instances
of TMBCSEncoding on initialization, one with codepage CP_ACP and 
another one with codepage CP_UTF8, both should exist on any windows 
system (AFAIK).    

> 
> So maybe somewhere in the code a wrong codepage is passed this this Win32 
> API call.

That won't raise an exception unless some wrapper function throwed one.

> So I searched all files in my project for "GetCPInfo" and compiled this 
> list:

OverbyteIcsCharsetUtils isn't included in the THttpCli and also won't raise 
an exception "Invalid Codepage". OverbyteIcsCharsetUtils is currently used by 
the SMTP, MimeDecoder and TIcsCharsetComboBox source only (if memory serves
well). The SMTP clients may raise an exception "Invalid charset". 
TMimeDecode may raise 'Code page "' + _IntToStr(Value) + '"' +
'is not a valid ANSI code page or currently not installed'.
In OverbyteIcsStreams TIcsStreamReader/Writer would throw an exception with
SysErrorMessage(ERROR_INVALID_PARAMETER) if GetCPInfo failed, however 
currently both classes are not yet used in ICS.   

--
Arno Garrels
--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to