Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2021-09

Code page for the Windows event viewer

5 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Abuy

Instead of cyrillic characters there some garbage in Windows event viewer. Have tried AnsiString with Windows-1251 code page (type StringCP1251 = type AnsiString(1251)) but this does not work. What works is RawByteString variable with the following conversion to Windows-1251. Here is code:

{$MODE objfpc} {$ifdef mswindows}{$apptype console}{$endif}
{$R C:\lazarus\fpc\3.2.0\source\packages\fcl-base\src\win\fclel.res}
program Project1;
uses
   EventLog,
   sysutils;
type
   StringCP1251 = type AnsiString(1251);
var
   logger:teventlog;
   //msg:StringCP1251;
   msg:rawbytestring;
begin
msg:='Іівівйц й вфівфъ2цву йцуцйівів';
SetCodePage(msg, 1251, True);
Write('DefaultSystemCodePage is ');
Writeln(system.DefaultSystemCodePage);
logger:=teventlog.create(nil);
logger.Identification:='My gressdqwwe';
logger.RegisterMessageFile('');
logger.logtype:=ltsystem;
logger.active:=true;
Write('Code page is ');
WriteLn(StringCodePage(msg));
logger.Info(msg);
logger.Destroy;
WriteLn('End');
end.

OS: English Windows XP.

Reply by email

Tomas Hajny
to Abuy
Abuy wrote 40 lines
Instead of cyrillic characters there some garbage in Windows event viewer. Have tried AnsiString with Windows-1251 code page (type StringCP1251 = type AnsiString(1251)) but this does not work. What works is RawByteString variable with the following conversion to Windows-1251. Here is code: {$MODE objfpc} {$ifdef mswindows}{$apptype console}{$endif} {$R C:\lazarus\fpc\3.2.0\source\packages\fcl-base\src\win\fclel.res} program Project1; uses EventLog, sysutils; type StringCP1251 = type AnsiString(1251); var logger:teventlog; //msg:StringCP1251; msg:rawbytestring; begin msg:='Іівівйц й вфівфъ2цву йцуцйівів'; SetCodePage(msg, 1251, True); Write('DefaultSystemCodePage is '); Writeln(system.DefaultSystemCodePage); logger:=teventlog.create(nil); logger.Identification:='My gressdqwwe'; logger.RegisterMessageFile(''); logger.logtype:=ltsystem; logger.active:=true; Write('Code page is '); WriteLn(StringCodePage(msg)); logger.Info(msg); logger.Destroy; WriteLn('End'); end.

What happens if you declare Msg as UnicodeString? How is your source file stored (which encoding, BOM if applicable or not)? Which command line parameters do you use (e.g. -Fc???)?

Tomas

Reply by email

Abuy
to Tomas Hajny

UnicodeString change only look of symbols (instead of quastion marks this — Іівівйц ГђВ№ вфівфъ2цву йцуцйівів). No BOM. File is UTF-8. No command line parameters.

Tomas Hajny wrote 50 lines
On 2021-09-15 15:08, Abuy via fpc-pascal wrote: > Instead of cyrillic characters there some garbage in Windows event > viewer. Have tried AnsiString with Windows-1251 code page (type > StringCP1251 = type AnsiString(1251)) but this does not work. What > works is RawByteString variable with the following conversion to > Windows-1251. Here is code: > > {$MODE objfpc} {$ifdef mswindows}{$apptype console}{$endif} > {$R C:\lazarus\fpc\3.2.0\source\packages\fcl-base\src\win\fclel.res} > program Project1; > > uses > EventLog, > sysutils; > type > StringCP1251 = type AnsiString(1251); > var > logger:teventlog; > //msg:StringCP1251; > msg:rawbytestring; > begin > msg:='Іівівйц й вфівфъ2цву йцуцйівів'; > SetCodePage(msg, 1251, True); > > Write('DefaultSystemCodePage is '); > Writeln(system.DefaultSystemCodePage); > > logger:=teventlog.create(nil); > logger.Identification:='My gressdqwwe'; > logger.RegisterMessageFile(''); > logger.logtype:=ltsystem; > logger.active:=true; > > Write('Code page is '); > WriteLn(StringCodePage(msg)); > > logger.Info(msg); > logger.Destroy; > > WriteLn('End'); > end. What happens if you declare Msg as UnicodeString? How is your source file stored (which encoding, BOM if applicable or not)? Which command line parameters do you use (e.g. -Fc???)? Tomas _______________________________________________ fpc-pascal maillist - https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply by email

Tomas Hajny
to Abuy
Abuy wrote 5 lines
UnicodeString change only look of symbols (instead of quastion marks this — Іівівйц ГђВ№ вфівфъ2цву йцуцйівів). No BOM. File is UTF-8. No command line parameters.

If your source file is in UTF-8, you need to let the compiler know about this. You can do so by using the compiler option -Fcutf8 (or by using the BOM, but the explicit option is the safest).

Tomas

Show quoted text 49 lines
On 15.09.2021 16:53, Tomas Hajny via fpc-pascal wrote: > On 2021-09-15 15:08, Abuy via fpc-pascal wrote: >> Instead of cyrillic characters there some garbage in Windows event >> viewer. Have tried AnsiString with Windows-1251 code page (type >> StringCP1251 = type AnsiString(1251)) but this does not work. What >> works is RawByteString variable with the following conversion to >> Windows-1251. Here is code: >> >> {$MODE objfpc} {$ifdef mswindows}{$apptype console}{$endif} >> {$R C:\lazarus\fpc\3.2.0\source\packages\fcl-base\src\win\fclel.res} >> program Project1; >> >> uses >> EventLog, >> sysutils; >> type >> StringCP1251 = type AnsiString(1251); >> var >> logger:teventlog; >> //msg:StringCP1251; >> msg:rawbytestring; >> begin >> msg:='Іівівйц й вфівфъ2цву йцуцйівів'; >> SetCodePage(msg, 1251, True); >> >> Write('DefaultSystemCodePage is '); >> Writeln(system.DefaultSystemCodePage); >> >> logger:=teventlog.create(nil); >> logger.Identification:='My gressdqwwe'; >> logger.RegisterMessageFile(''); >> logger.logtype:=ltsystem; >> logger.active:=true; >> >> Write('Code page is '); >> WriteLn(StringCodePage(msg)); >> >> logger.Info(msg); >> logger.Destroy; >> >> WriteLn('End'); >> end. > > What happens if you declare Msg as UnicodeString? How is your source > file stored (which encoding, BOM if applicable or not)? Which command > line parameters do you use (e.g. -Fc???)? > > Tomas

Reply by email

Abuy
to Tomas Hajny

No change.

Tomas Hajny wrote 66 lines
On 2021-09-15 16:09, Abuy via fpc-pascal wrote: > UnicodeString change only look of symbols (instead of quastion marks > this — Іівівйц ГђВ№ > вфівфъ2цву > йцуцйівів). No BOM. File is UTF-8. No > command line parameters. If your source file is in UTF-8, you need to let the compiler know about this. You can do so by using the compiler option -Fcutf8 (or by using the BOM, but the explicit option is the safest). Tomas > > On 15.09.2021 16:53, Tomas Hajny via fpc-pascal wrote: >> On 2021-09-15 15:08, Abuy via fpc-pascal wrote: >>> Instead of cyrillic characters there some garbage in Windows event >>> viewer. Have tried AnsiString with Windows-1251 code page (type >>> StringCP1251 = type AnsiString(1251)) but this does not work. What >>> works is RawByteString variable with the following conversion to >>> Windows-1251. Here is code: >>> >>> {$MODE objfpc} {$ifdef mswindows}{$apptype console}{$endif} >>> {$R C:\lazarus\fpc\3.2.0\source\packages\fcl-base\src\win\fclel.res} >>> program Project1; >>> >>> uses >>> EventLog, >>> sysutils; >>> type >>> StringCP1251 = type AnsiString(1251); >>> var >>> logger:teventlog; >>> //msg:StringCP1251; >>> msg:rawbytestring; >>> begin >>> msg:='Іівівйц й вфівфъ2цву йцуцйівів'; >>> SetCodePage(msg, 1251, True); >>> >>> Write('DefaultSystemCodePage is '); >>> Writeln(system.DefaultSystemCodePage); >>> >>> logger:=teventlog.create(nil); >>> logger.Identification:='My gressdqwwe'; >>> logger.RegisterMessageFile(''); >>> logger.logtype:=ltsystem; >>> logger.active:=true; >>> >>> Write('Code page is '); >>> WriteLn(StringCodePage(msg)); >>> >>> logger.Info(msg); >>> logger.Destroy; >>> >>> WriteLn('End'); >>> end. >> >> What happens if you declare Msg as UnicodeString? How is your source >> file stored (which encoding, BOM if applicable or not)? Which command >> line parameters do you use (e.g. -Fc???)? >> >> Tomas _______________________________________________ fpc-pascal maillist - https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply by email