fxphp icon indicating copy to clipboard operation
fxphp copied to clipboard

preg_replace_callback handling of danish characters

Open webformdk opened this issue 10 years ago • 4 comments

After latest version of FX.php where 'preg_replace' was changed to ‘preg_replace_callback’ in RetrieveFMXML.class.php, FX.php no longer display danish characters like æøå correctly - They output more like japanese characters!

webformdk avatar Oct 15 '14 12:10 webformdk

Persistent problem, this. Has a solution been identified?

An example: "é" {Char(223)} is in my database field is transformed to "ラ" {char(12521)} by FX for browser display**. When I revert RetrieveFMXML.class.php file to the older version (using deprecated 'preg_replace'.), it properly displays "é" in browser.

** using latest download of FX.php from github on running with PHP5.5/Apache2.4, FMS 14.

How can I get it to correctly handle special unicode characters?

aragon66 avatar Aug 12 '16 21:08 aragon66

I am not where I can test this right now, but if you replace this function on line 51 of RetrieveFMXML.class.php does it work?

function utf8HTMLEntities($matches) {
    // $matches contains full match as first item so everything is +1
    if(count($matches) == 3){
        return $this->FX->BuildExtendedChar($matches[1],$matches[2]);
    }elseif(count($matches) == 4){
        return $this->FX->BuildExtendedChar($matches[1],$matches[2],$matches[3]);
    }elseif(count($matches) == 5){
        return $this->FX->BuildExtendedChar($matches[1],$matches[2],$matches[3],$matches[4]);
    }
return ''; // TODO something went wrong, but this should be explicit someday
}

APD183 avatar Aug 12 '16 23:08 APD183

Yes, that revised function appears to deliver the correct characters!

Does this fix or break things for anyone else?

On Fri, Aug 12, 2016 at 7:05 PM, Andrew Denman [email protected] wrote:

function utf8HTMLEntities($matches) { // $matches contains full match as first item so everything is +1 if(count($matches) == 3){ return $this->FX->BuildExtendedChar($matches[1],$matches[2]); }elseif(count($matches) == 4){ return $this->FX->BuildExtendedChar($matches[1],$matches[2],$matches[3]); }elseif(count($matches) == 5){ return $this->FX->BuildExtendedChar($matches[1],$matches[2],$matches[3],$matches[4]); } }

aragon66 avatar Aug 12 '16 23:08 aragon66

It appears to me that this fix is present in the current version of FX.php (version 6.10 as of this writing.) I'm trying to address a bunch of things right now, so please let me know if this is not fixed at this point.

yodarunamok avatar Mar 11 '17 23:03 yodarunamok