[fpc-pascal] How to create AnsiString with specific code page?
I need string with Windows-1251. Tried var msg: AnsiString(1251) but this does not work. What I am doing now is var msg: rawbytestring; begin SetCodePage(msg, 1251, True); end. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] How to create AnsiString with specific code page?
On Wed, Sep 15, 2021 at 12:14 PM Abuy via fpc-pascal wrote: > I need string with Windows-1251. Tried var msg: AnsiString(1251) but > this does not work. What I am doing now is This should work type StringCP1251 = AnsiString(1251) var S: StringCP1251; -- Bart ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] How to create AnsiString with specific code page?
On Wed, Sep 15, 2021 at 12:32 PM Bart wrote: > This should work > > type > StringCP1251 = AnsiString(1251) That should be type StringCP1251 = type AnsiString(1251); -- Bart ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
[fpc-pascal] Code page for the Windows event viewer
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. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Code page for the Windows event viewer
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 - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Code page for the Windows event viewer
UnicodeString change only look of symbols (instead of quastion marks this — Іівівйц ГђВ№ вфівфъ2цву йцуцйівів). No BOM. File is UTF-8. No command line parameters. 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 - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal