Skip to content

preg_replace_callback handling of danish characters #32

Description

@webformdk

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!

Activity

  1. aragon66 commented on Aug 12, 2016

    @aragon66

    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?

  2. APD183 commented on Aug 12, 2016

    @APD183
    Contributor

    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
    }
    
  3. aragon66 commented on Aug 12, 2016

    @aragon66

    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 notifications@github.com
    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]);
    }
    }

  4. yodarunamok commented on Mar 11, 2017

    @yodarunamok
    Owner

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions