Issue with parsing rich text tags with RTL Fixer

More
1 week 5 days ago #3989 by bkane
Hi Frank,

I think I've found an issue with strings that contain rich text tags when using RTL languages. To reproduce, create a term with this string:

English:
<color=blue>Hello</color>.
Arabic:
<color=blue>مرحبا</color>.

When you perform the localization, the fixed text ends up as:
@@.鱁@@ﺎﺒﺣﺮﻣ</color>

You can see the RTLFixer is pulling the period "." into the tag substitution, which prevents it from being converted back into the rich text tag. Note that if you were to add a space (" ") character at the end of the string, the substitution would work properly.

I believe the issue is in RTLFixer.cs in "FixLine(string str)" on line 615 where the check is:
if (char.IsPunctuation(lettersFinal[i]) && i > 0 && i < lettersFinal.Length - 1 &&
 (char.IsPunctuation(lettersFinal[i - 1]) || char.IsPunctuation(lettersFinal[i + 1])))

I believe the bounds check here just needs reworked to something like this:
if (char.IsPunctuation(lettersFinal[i]) &&
    (i > 0 && (char.IsPunctuation(lettersFinal[i - 1])) ||
    (i < lettersFinal.Length - 1 && char.IsPunctuation(lettersFinal[i + 1]))))

Hope that helps!
- Ben

i2Loc version: 2.8.13f1
Unity: 2017.4.22f1
Platform: Windows
Target: Unity 3D Text

Please Log in or Create an account to join the conversation.

Time to create page: 0.174 seconds
Template by JoomlaShine