Re: [fpc-pascal] Concatenating CP Strings

2018-09-16 Thread Martok
Am 16.09.2018 um 14:31 schrieb Jonas Maebe: > [...snip...] Thank you very much for this explanation! One for the bookmarks. It just seems very odd to me to have the incredibly powerful and useful dynamic codepage concept... and then trash it on every assignment. But if that was an Emba-invention,

Re: [fpc-pascal] Concatenating CP Strings

2018-09-16 Thread Jonas Maebe
On 16/09/18 13:31, Martok wrote: Let's say the user directs a program to "treat this file as $codepage". Therefore, I need to read it as this codepage and fill internal data structures with strings in that codepage, while keeping other operations in the system codepage (so I can't just change Def

Re: [fpc-pascal] Concatenating CP Strings

2018-09-16 Thread Martok
Am 16.09.2018 um 12:35 schrieb Sven Barth via fpc-pascal: > If you want the content to *be* in code page 866 without any tricks then > you need to declare a AnsiString with that code page and use that: > > === code begin === > > type > TCP866String = type AnsiString(866); That only works if the

Re: [fpc-pascal] Concatenating CP Strings

2018-09-16 Thread Sven Barth via fpc-pascal
On 9/15/18 1:38 AM, Martok wrote: > Hi all, > > concatenating codepage strings is documented to be a bit weird: > > > Knowing this, how does one achieve the following? > > - have a string in any dynamic codepage > - append an

Re: [fpc-pascal] Concatenating CP Strings

2018-09-16 Thread Sven Barth via fpc-pascal
On 9/15/18 10:12 PM, Martok wrote: > And another one: > > var > f: TextFile; > s: string; > begin > AssignFile(f, 'a_file.txt'); > SetTextCodePage(f, 866); > Reset(f); > ReadLn(f, s); > WriteLn(StringCodePage(s)); > readln; > end. > > That is rather useless... No, it is not. The

Re: [fpc-pascal] Concatenating CP Strings

2018-09-15 Thread Martok
> Setting the code page of a file tells the RTL about the encoding of the > strings in the file. The string's static code page (which maps to > DefaultSystemCodePage if none is specified) tells the compiler to which > encoding this string data should be converted. I know! That doesn't make it

Re: [fpc-pascal] Concatenating CP Strings

2018-09-15 Thread Jonas Maebe
On 15/09/18 22:32, Martok wrote: Gah, accidentally removed the comment that said what the actual problem is ;-) ReadLn(f, s); WriteLn(StringCodePage(s)); That prints 1252, which is the DefaultSystemCodePage. At that point, information loss has already occured, there is no way to fix the

Re: [fpc-pascal] Concatenating CP Strings

2018-09-15 Thread Martok
Gah, accidentally removed the comment that said what the actual problem is ;-) > ReadLn(f, s); > WriteLn(StringCodePage(s)); That prints 1252, which is the DefaultSystemCodePage. At that point, information loss has already occured, there is no way to fix the CP in user code. I would expect re

Re: [fpc-pascal] Concatenating CP Strings

2018-09-15 Thread Martok
And another one: var f: TextFile; s: string; begin AssignFile(f, 'a_file.txt'); SetTextCodePage(f, 866); Reset(f); ReadLn(f, s); WriteLn(StringCodePage(s)); readln; end. That is rather useless... Writing anything into the specified codepage works perfectly fine. -- Regards, M

Re: [fpc-pascal] Concatenating CP Strings

2018-09-15 Thread Martok
Am 15.09.2018 um 07:34 schrieb Mattias Gaertner via fpc-pascal: > To have the result in a specific codepage use > SetCodePage(result,NeededCP,true); As I wrote, doing this by hand works, but I don't want to believe somebody thought that was how it should be. Why would "CP_UTF16 + CP_UTF8(literal) =

Re: [fpc-pascal] Concatenating CP Strings

2018-09-14 Thread Mattias Gaertner via fpc-pascal
On Sat, 15 Sep 2018 01:38:33 +0200 Martok wrote: > Hi all, > > concatenating codepage strings is documented to be a bit weird: > > > Knowing this, how does one achieve the following? > > - have a string in any dynamic codep

[fpc-pascal] Concatenating CP Strings

2018-09-14 Thread Martok
Hi all, concatenating codepage strings is documented to be a bit weird: Knowing this, how does one achieve the following? - have a string in any dynamic codepage - append another string (possibly from different CP), or a lite