Search code examples
opentbs

Opentbs upper not working for special chars like æøå


I have been stuck for a while with this issue.

When I merge a field and want it sent to uppercase I normaly use [onshow.field;ope=upper] and it works great for almost all fields but we are sometimes using special chars like æ, ø and å and these are not being sent to upper like the rest.

Are there anyone that know what could be wrong?


Solution

  • Going through the source code of OpenTBS and searching for "upper", you get to the cryptic constant "15", which signifies conversion to uppercase. It actually does support Unicode conversion:

    ($Loc->OpeUtf8) ? mb_convert_case($CurrVal, MB_CASE_UPPER, 'UTF-8') : strtoupper($CurrVal)
    

    And to enable Unicode, it seems that you also need ope=utf8. It seems that you can have multiple filters by separating them with a comma, so in your template, you can write:

    [onshow.field;ope=utf8,upper]
    

    Or you could change the source code to always support Unicode by default on line 1293:

    $Loc->OpeUtf8 = true;