Recent

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

Pascal

  • Hero Member
  • *****
  • Posts: 932
[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 (21H2)

Thaddy

  • Hero Member
  • *****
  • Posts: 14364
  • Sensorship about opinions does not belong here.
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.
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

Pascal

  • Hero Member
  • *****
  • Posts: 932
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 (21H2)

PascalDragon

  • Hero Member
  • *****
  • Posts: 5469
  • 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: 932
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 (21H2)

 

TinyPortal © 2005-2018