Forum > General

concatenate two ansistring in console application

<< < (2/4) > >>

jamie:
change the "AnsiString" to a "RawByteString"


or

Utf8String;

cdbc:
Hi
Thaddy, that was sort of what I meant by:
--- Quote ---the codepage modifier lets you use unicode literals in source...
--- End quote ---
Regards Benny

tetrastes:

--- Quote from: wp on March 03, 2024, 04:20:45 pm ---SetConsoleOutput() has no effect on my system...

--- End quote ---

Try this

--- 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 concat1;{$mode objfpc}{$H+}uses  LazUTF8,  windows;var  s1, s2, s3: AnsiString;begin  SetConsoleOutputCP(CP_UTF8);  s1 := '春夏';  s2 := '秋冬';  writeln(s1, #13#10, s2);  writeln(pchar(s1), #13#10, pchar(s2));  s3 := s1 + s2;  writeln(s3);  writeln(pchar(s3));  readln;end. with different CPs in SetConsoleOutputCP, and with and without LazUTF8.

marcov:
In Lazarus go to settings->application , enable manifest and utf-8 codepage.

wp:

--- Quote from: tetrastes on March 03, 2024, 10:01:24 pm ---Try this [...] with different CPs in SetConsoleOutputCP, and with and without LazUTF8.

--- End quote ---
A very non-Pascal-ish way to use WriteLn...


--- Quote from: marcov on March 03, 2024, 10:08:08 pm ---In Lazarus go to settings->application , enable manifest and utf-8 codepage.

--- End quote ---
Ah, the code in the first post does show the utf8 characters when the app runs in the IDE if
- that utf8-manifest is active
- SetConsoleOutputCP has been set to UTF8.
But still no UTF8 when "ordinary" Pascal strings are in the WriteLn. For this, I have to run the exe separately in a console window for which I had changed codepage manually to 65001.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version