Recent

Author Topic: [Solved] SetCodePage can raise an exception?  (Read 215 times)

AlexTP

  • Hero Member
  • *****
  • Posts: 2046
    • UVviewsoft
[Solved] SetCodePage can raise an exception?
« on: December 25, 2022, 12:35:20 pm »
SetCodePage calls fpc_AnsiStr_To_AnsiStr, I cannot find its code in 'fpcsrc' yet. Can it raise an exception (or set another error flag) on conversion error? I need that exception - my app wants to check is some encoding applicable to a file or not.

PS. I found the source - fpc_AnsiStr_To_AnsiStr calls widestringmanager methods. But I cannot find their src yet.
« Last Edit: December 25, 2022, 01:05:15 pm by AlexTP »

Thaddy

  • Hero Member
  • *****
  • Posts: 12933
Re: SetCodePage can raise an exception?
« Reply #1 on: December 25, 2022, 12:51:36 pm »
The sources for the default widestring manager are in rtl.
In memory of Gordon Moore  (January 3, 1929 – March 24, 2023) Just double the heaven every two years from now.

Bart

  • Hero Member
  • *****
  • Posts: 4934
    • Bart en Mariska's Webstek
Re: SetCodePage can raise an exception?
« Reply #2 on: December 25, 2022, 12:53:46 pm »
AFAICS by testing it will return an empty string if it cannot convert.

Bart

AlexTP

  • Hero Member
  • *****
  • Posts: 2046
    • UVviewsoft
Re: SetCodePage can raise an exception?
« Reply #3 on: December 25, 2022, 01:05:03 pm »
Thanks, empty str is OK for me.

Bart

  • Hero Member
  • *****
  • Posts: 4934
    • Bart en Mariska's Webstek
Re: [Solved] SetCodePage can raise an exception?
« Reply #4 on: December 25, 2022, 01:10:41 pm »
Someone with more knowledge (an fpc devel) should confirm this.
My conclusion is based upon very limited testing!

Bart

Thaddy

  • Hero Member
  • *****
  • Posts: 12933
Re: [Solved] SetCodePage can raise an exception?
« Reply #5 on: December 25, 2022, 01:24:36 pm »
I have the same conclusion as Bart, also after very limited testing, but I am not a devel.
Anyway, you can write your own exception handler if empty.
In memory of Gordon Moore  (January 3, 1929 – March 24, 2023) Just double the heaven every two years from now.

 

TinyPortal © 2005-2018