Lazarus

Free Pascal => General => Topic started by: Zoran on September 24, 2022, 11:10:34 am

Title: SetCodePage behaviour
Post by: Zoran on September 24, 2022, 11:10:34 am
The official documentation (https://www.freepascal.org/docs-html/current/rtl/system/setcodepage.html) 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...?
Title: Re: SetCodePage behaviour
Post by: Thaddy on September 24, 2022, 11:14:33 am
What makes you think so?
A small example will help.
Title: Re: SetCodePage behaviour
Post by: Jonas Maebe on September 24, 2022, 11:16:45 am
The character will be replaced with '?'
Title: Re: SetCodePage behaviour
Post by: Zoran 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. :)
TinyPortal © 2005-2018