Recent

Author Topic: [SOLVED] How to set CodePage of File of char?  (Read 327 times)

Pascal

  • Hero Member
  • *****
  • Posts: 914
[SOLVED] How to set CodePage of File of char?
« 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.
« Last Edit: October 20, 2020, 04:29:19 pm by Pascal »
laz trunk x64 - fpc trunk i386 (cross x64) - Windows 10 Pro x64 (2004)

Thaddy

  • Hero Member
  • *****
  • Posts: 10582
Re: How to set CodePage of File of char?
« Reply #1 on: October 20, 2020, 12:50:52 pm »
You don't need to: a file of char is basically just bytes.

Pascal

  • Hero Member
  • *****
  • Posts: 914
Re: How to set CodePage of File of char?
« Reply #2 on: October 20, 2020, 01:11:50 pm »
So i have to do converting myself, right?
laz trunk x64 - fpc trunk i386 (cross x64) - Windows 10 Pro x64 (2004)

PascalDragon

  • Hero Member
  • *****
  • Posts: 2424
  • Compiler Developer
Re: How to set CodePage of File of char?
« Reply #3 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(yourstr, yourcp, False) which will set the code page without converting the string.

Pascal

  • Hero Member
  • *****
  • Posts: 914
Re: How to set CodePage of File of char?
« Reply #4 on: October 20, 2020, 04:28:56 pm »
Many thanks for the hints!
laz trunk x64 - fpc trunk i386 (cross x64) - Windows 10 Pro x64 (2004)

 

TinyPortal © 2005-2018