Recent

Author Topic: SetCodePage behaviour  (Read 458 times)

Zoran

  • Hero Member
  • *****
  • Posts: 1829
    • http://wiki.lazarus.freepascal.org/User:Zoran
SetCodePage behaviour
« on: September 24, 2022, 11:10:34 am »
The official documentation says nothing about how SetCodePage behaves when the string parameter contains characters which cannot be converted to resulting code page.

So, the question is, when calling this function with Convert parameter set to true, and the string contains some character that cannot be represented in new code page, will it raise some exception, or simply ignore it, or...?

Thaddy

  • Hero Member
  • *****
  • Posts: 14213
  • Probably until I exterminate Putin.
Re: SetCodePage behaviour
« Reply #1 on: September 24, 2022, 11:14:33 am »
What makes you think so?
A small example will help.
Specialize a type, not a var.

Jonas Maebe

  • Hero Member
  • *****
  • Posts: 1058
Re: SetCodePage behaviour
« Reply #2 on: September 24, 2022, 11:16:45 am »
The character will be replaced with '?'

Zoran

  • Hero Member
  • *****
  • Posts: 1829
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: SetCodePage behaviour
« Reply #3 on: September 24, 2022, 11:25:21 am »
The character will be replaced with '?'

Thank you, Jonas!

What makes you think so?
A small example will help.

Thaddy, you misunderstood, I didn't think "so", as I didn't assume anything.
I just wanted to be sure, how to write the code to handle this situation -- should I enclose it in try-except or do it some other way.

So now I know.
And, by the way, I will handle it with doing nothing, as the default behaviour with "?" will be quite satisfying for what I need. :)
« Last Edit: September 24, 2022, 11:31:32 am by Zoran »

 

TinyPortal © 2005-2018