Lazarus

Programming => General => Topic started by: Pascal on October 20, 2020, 12:23:50 pm

Title: [SOLVED] How to set CodePage of File of char?
Post by: Pascal on October 20, 2020, 12:23:50 pm
How can i set the CodePage of a File of char?

There is SetTextCodePage but only for Text files.
Title: Re: How to set CodePage of File of char?
Post by: Thaddy on October 20, 2020, 12:50:52 pm
You don't need to: a file of char is basically just bytes.
Title: Re: How to set CodePage of File of char?
Post by: Pascal on October 20, 2020, 01:11:50 pm
So i have to do converting myself, right?
Title: Re: How to set CodePage of File of char?
Post by: PascalDragon on October 20, 2020, 01:14:05 pm
file of X types are block based files (even if the block size is 1 if you use Char or Byte). For these the concept of code pages is not relevant. So either use TextFile or read the string data and then use SetCodePage (https://www.freepascal.org/docs-html/rtl/system/setcodepage.html)(yourstr, yourcp, False) which will set the code page without converting the string.
Title: Re: How to set CodePage of File of char?
Post by: Pascal on October 20, 2020, 04:28:56 pm
Many thanks for the hints!
TinyPortal © 2005-2018