1. Jozef Turóci
  2. PowerBuilder
  3. Friday, 13 January 2023 10:22 AM UTC

Hi,

we upgraded from PB2019 to PB2022 (1892) and we are experiencing another issues:

1) SetprofileString function has problem with special characters that contains diacritics "ľčť" when writing into INI file.

In INI file there is "lct" as result.

2) ReplaceA function, the same problem as 1), Replace function works fine. Pls see the image below :

Both problem happens RANDOMLY, after restarting application it is fine for some time.

Only once one of our developers succeeded to reproduce the problem, so he could debug it. (printscreen from debug)

BUT after restarting Powerbuilder, both issues were fine and he wasnt able to reproduce it anymore.

We can use Retrieve instead of RetrieveA, but for SetProfileString we have no workaround.

In PB2019 it all works fine.

Thanks for help.

Regards

Jozef

 

 

John Fauss Accepted Answer Pending Moderation
  1. Wednesday, 25 January 2023 18:25 PM UTC
  2. PowerBuilder
  3. # 1

Hi, Jozef - 

I'm struggling to understand why you are using the ReplaceA PowerScript function, since according to its description in PB Help, it temporarily converts a string to Double-Byte Character Set (DBCS) based on the current locale, then places a portion of one string with another.

PB uses Unicode (specifically, UnicodeUTF16LE encoding) internally and has since version 10 was released in 2004. DBCS was designed to support character sets that contain more than 256 (single-byte) code points, such as Kanji.

DBCS and Unicode are not equivalent:

   https://learn.microsoft.com/en-us/windows/win32/intl/double-byte-character-sets

Perhaps this is a factor in the problem you are experiencing?

My tests last night using SetProfileString with PB 2019 R3 and PB 2022 Build 1892 run flawlessly, as long as the INI file is initially created using UnicodeUTF16LE encoding. I did NOT attempt using the ReplaceA PowerScript function, as there seems to be no reason for doing so.

Best regards, John

Comment
There are no comments made yet.
Jozef Turóci Accepted Answer Pending Moderation
  1. Tuesday, 24 January 2023 15:48 PM UTC
  2. PowerBuilder
  3. # 2

Hi Chris,

 we changed INI file encoding to UTF16LE, but it didn't help.

Both issues (Setprofilestring and ReplaceA) are somehow connected, same with the issue with decimal numbers I wrote here. (https://www.appeon.com/standardsupport/search/view?id=9475)

On the same machine in debug:

We are very sad with the RANDOMNESS through our system, therefore we are not able to reproduce it for you.

We suppose its related to our regional settings. After restarting PB IDE/runtime APP it is fine for some time.

Regards.

Jozef

Comment
  1. Andreas Mykonios
  2. Tuesday, 24 January 2023 16:11 PM UTC
It's normal. As Roland Smith said, the ini must be ansi.

Andreas.
  1. Helpful
  1. Chris Pollach @Appeon
  2. Tuesday, 24 January 2023 20:19 PM UTC
Hi Andres;



No, INI files can be Unicode if they are initialized that way when created.



@ Josef ...

Note that ReplaceA is and ANSI command and not Unicode!



Regards ... Chris
  1. Helpful 1
  1. Andreas Mykonios
  2. Wednesday, 25 January 2023 07:31 AM UTC
Hi Chris.

Of course you are right. UTF16LE works.

Andreas.
  1. Helpful
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Friday, 13 January 2023 19:17 PM UTC
  2. PowerBuilder
  3. # 3

Hi Jozef;

   The issue might be how the INI file was created. For example in Notepad when creating an INI file ...

  Note that you can change the default UTF-8 to UTF-16LE to match the default encoding of both the MS-Windows O/S and also the PB IDE & runtime which use UTF-16LE as well. UTF-16LE encoding should support the full extended character set whereas, UTF-8 does not.

Food for thought.  HTH

Regards ... Chris

 

Comment
  1. Benjamin Gaesslein
  2. Wednesday, 25 January 2023 08:28 AM UTC
What characters does UTF-8 supposedly not support? UTF-8 is capable of encoding all Unicode code points, same as UTF-16. Unlike UTF-16, it is compatible with ASCII.
  1. Helpful
  1. Chris Pollach @Appeon
  2. Wednesday, 25 January 2023 15:01 PM UTC
Hi Benjamin;

Yes, UTF-8 supports the "extended" character set but does that via using 2 to 4 bytes internally to represent the one extended character.

Whereas in UTF-16LE encoding, the standard & extended character sets are represented internally by always using 2 bytes -

which the MS-Windows O/S uses by default as well.

HTH

Regards ... Chris
  1. Helpful
  1. Benjamin Gaesslein
  2. Thursday, 26 January 2023 08:06 AM UTC
That's not quite correct: UTF-8 is indeed a variable-length encoding and works with 8-bit code units. Hence, UTF-8 encoded characters can be as short as one byte. UTF-16 does *not* encode all characters in 2 bytes. It's also variable-length but uses 16-bit code units, so it's either 2 bytes or 4 bytes. There are more than 2^16 code points, 2 bytes are not enough for Unicode.



Using UTF-16LE for the ini is necessary because the ProfileString functions expect this encoding, not because UTF-8 can't handle the characters. (The help file says "ProfileInt, ProfileString, and SetProfileString can read or write to files with ANSI or UTF16-LE encoding on Windows systems, and ANSI or UTF16-BE encoding on UNIX systems.")
  1. Helpful
There are no comments made yet.
Armeen Mazda @Appeon Accepted Answer Pending Moderation
  1. Friday, 13 January 2023 17:16 PM UTC
  2. PowerBuilder
  3. # 4

Please open a support ticket and provide a test case. Thanks.  https://www.appeon.com/standardsupport/newbug

 

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.