Forum > Windows

Questions of new Strings in FPC 3.0

<< < (3/4) > >>

Cyrax:
Check out attached demo project. It should shine some light for this matter.

Cyrax:
And I think I managed to solve Michl's problem. Downside is that you need to change console font every time when you execute your console program and maybe restore to default font.

See attached project for more info.

Michl:

--- Quote from: Cyrax on October 29, 2015, 04:59:00 pm ---Check out attached demo project. It should shine some light for this matter.

--- End quote ---
You make the goal! The shown codepage in the console is cp850 for the files cp1252. 

If I change the project to something like
--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---program project1; {$codepage cp1252}{$mode ObjFPC}{$H+} uses windows; var  s: String;  s2: ShortString; begin  System.SetTextCodePage(Output, 1252);  s := #$80#$C4#$D6#$8C#$A5;  s2 := #$80#$C4#$D6#$8C#$A5;  writeln(s);   // get: Ç─ÍîÑ  writeln(s2);  // get: Ç─ÍîÑend.
I now got the same result for both, ShortString and String. It is a string represented by chars of codepage 850.

Quite confusing. I must first digest it.




--- Quote from: marcov on October 29, 2015, 04:51:23 pm ---Console is in OEMSTRING:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---type  OemString = type AnsiString(CP_OEMCP);
if not already predefined.

--- End quote ---
A direct assigning of a constant to that new defined string doesn't work, only from a other string. But this is a new topic.


For me it was important to understand, if the statement "Shortstring: The code page of a shortstring is implicitly CP_ACP and hence will always be equal to the current value of DefaultSystemCodePage." is correct.
For files it is.
For the console too, but you can't get the displayed codepage with DefaultSystemCodePage, but with System.GetTextCodePage(Output).


Thank you all! For me this topic is solved!

I think, I'll create a new thread for a new topic.

Michl:

--- Quote from: Cyrax on October 29, 2015, 06:07:10 pm ---And I think I managed to solve Michl's problem. Downside is that you need to change console font every time when you execute your console program and maybe restore to default font.

See attached project for more info.

--- End quote ---
Very nice!!! The name of the unit isn't correct any more ;)

Maybe it is good for a feature request, that the codepage for the console is the same as for files, the DefaultSystemCodePage?

Michl:
A new day, new tests.

Your project compiles fine on command line. If I compile your project with Lazarus I got a Runerror 103 on line "  WriteLn(StrCP1252);    ". I understand also why, cause your project file is saved with CP1252 - the DefaultSystemCodePage.

If I create an new program with Lazarus and copy the content of your project file in the new project file and compile it, it works but now the String "  WriteLn('€ÄÖŒ¥'); " is a UTF8-String. If I compile the new created project on command line there is the same, cause Lazarus saves the project file as a UTF8-File.

So here we have the issue, that with Lazarus it is never possible to build clean CP_APC projects, cause Lazarus saves the project file as UTF8, so the compiler interprets all the time the saved strings as UTF8. It is also not possible to compile such a UTF8 project from command line, the result is the same. I'm right???

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version