Hello
If I understand the problem correctly the error only occurs when certain non-arabic characters come at the end of an arabic string,while I don't have a satisfying solution for this "but I'll surely search for one" I came up with a workaround ,a rather Ugly one

.
You need to make sure that the Exclamation mark doesn't come last by appending an arabic letter to the string,instead of appending a full sized letter you can append tiny letter that hardly appears,it's what we call "Tashkeel" or Diacritics,they are considered letters internally by the rendering engine,however, they're not quite visible to the viewers.
Here's a sample of how it works
Before:Code:
شيئ غريب!
After:Code:
شيئ غريب!ﹺ
in order to use this copy and paste the following character after your Exclamation mark.
Code:
ﹺ
Ofcourse this is not the best way around,I'll do some research on that issue I'll let you know if I find anything.