1

I'm comparing variable with value. The results seems different with languages like I've tried Swedish/English/Dutch/Portugese and Turkish.

<#assign fm_bidBucket>Install</#assign>
<#assign _text><#if fm_bidBucket?trim?lower_case == "both">both-<#elseif fm_bidBucket?trim?lower_case == "install">install-<#else>else-</#if></#assign>
${_text}

Output:
In case of any language: install-
In case of Turkish language: else-

But if we change the condition with upper_case instead of lower case it is working as expected.

<#assign fm_bidBucket>Install</#assign>
<#assign _text><#if fm_bidBucket?trim?upper_case == "both">both-<#elseif fm_bidBucket?trim?upper_case == "install">install-<#else>else-</#if></#assign>
${_text}

Output:
In case of any language: install-
In case of Turkish language: install-

or if we change the content of condition then it is working fine.

<#assign fm_bidBucket>Siddharth</#assign>
<#assign _text><#if fm_bidBucket?trim?lower_case == "both">both-<#elseif fm_bidBucket?trim?lower_case == "siddharth">install-<#else>else-</#if></#assign>
${_text}

Output:
In case of any language: install-
In case of Turkish language: install-

I'm not able to trace the issue why I'm getting different output in case of Turkish locale only and with text "install".

Also, want to know if there is any other character in any other locale working like this.

I've Tried running this code on http://try.freemarker.org/ as well and got the similar response.

Siddharth Jain
  • 118
  • 1
  • 14

1 Answers1

2

You just encountered the famous Turkish locale bug.

The Turkish language contain both i (Unicode LATIN SMALL LETTER I) and ı (Unicode LATIN SMALL LETTER DOTLESS I), and ı is the lowercase letter for I.

For example "INSTALL".toLowerCase() is equal to "ınstall", which is different from "install".

It is documented in the javadoc of String.toLowerCase and String.toUpperCase.

There is also a bug report that says the problem could also happen with the Azeri locale (az_AZ). The only other character I know which can cause problem is the German ß.

obourgain
  • 8,856
  • 6
  • 42
  • 57
  • Thanks for the prompt response, but why it is happening when we have "i" in the beginning of word and not when it is between. Like if you check the case above it is working fine if I use Siddharth or Title as a text. – Siddharth Jain Oct 06 '17 at 08:24
  • Because in your case, only first letter is uppercased. `"Install".toLowerCase() = "ınstall"`, and `"Siddharth".toLowerCase() = "shiddharth"`. In the second case, Turkish behave exactly like English. – obourgain Oct 06 '17 at 08:31
  • If it means if conversion of character takes place using toLowerCase() then only it matches the exact text. – Siddharth Jain Oct 06 '17 at 08:36