0

I have an issue when reading RTL strings from Db2 for IBM i using C#. I tried enabling the bi-directional strings on IBM i Client Access and have the same issue as here.

I am using IIS 10.

So they seem to have written a function that fixes the strings; but I am having trouble because the strings have mixed Hebrew and English, and the words are not in the right order as well.

I tried reversing the whole string and then re-reversing the Latin and numeric characters, and sometimes the final letter still wraps around to the start. I'll keep trying to get it right but hopefully the algorithm to fix this is already out there... I can't find it.

What I did find is that when setting Console.OutputEncoding to Encoding.UTF8 it seems to be able to fix everything since the console printing is actually perfect. Does anyone have an idea how or why that is?

tl;dr: bi-directional strings are returning reversed, but only the non-English bits and brackets (I think, not clear). Any ideas on fixes?

John Y
  • 14,123
  • 2
  • 48
  • 72
  • I don't quite understand what you are asking. If using UTF-8 as the console output encoding is "able to fix everything", then... why can't you make use of that? – John Y Apr 13 '22 at 15:31
  • because that prints to the console and not to a file, but when I'm writing to a file(even if the writer is configured as UTF8) then it still comes out wrong. – SimplePersonSimpleBanana Apr 13 '22 at 15:35
  • I have to imagine there is some reasonably straightforward way to make a file writer generate the same output as a console. However, failing that, you could try [redirecting console output to a file](https://stackoverflow.com/questions/4470700/how-to-save-console-writeline-output-to-text-file). – John Y Apr 13 '22 at 17:26
  • I tried that, still comes out reversed, which is even more confusing – SimplePersonSimpleBanana Apr 14 '22 at 09:04

1 Answers1

1

Setting the Application Pool IIS user as a local user rather then the default solved the problem. Go to ApplicationPools -> Choose your application pool -> Advanced Settings -> Process Model -> Identity -> the ... when you hover the value -> Custom User.

Type in a local user credentials and it worked for me