Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 995367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T06:42:41+00:00 2026-05-16T06:42:41+00:00

So to start, I have an array of XML files. These files need to

  • 0

So to start, I have an array of XML files. These files need to be iterated through and checked for certain ‘unrecognized’ hexadecimal characters and replaced with normal UTF-8 text, or some kind of placeholder.

I’ve tried iterating through the files and replacing the hex codes using both str_replace and preg_replace with no luck. My ultimate problem, is I’m receiving errors about ‘non-utf characters’ when trying to open these files with simpleXML.

Here’s what I have so far:

class HexadecimalConverter {

    public $filenames = array();

    public function __construct($filenames) {

        $this->filenames = $filenames;
        $this->removeHex();

    }

    public function removeHex() {

        foreach ($this->filenames as $key => $value) {

            $contents = file_get_contents($value);

            $contents = preg_replace("/\x96/", '–', $contents);
            $contents = preg_replace("/\x97/", '—', $contents);
            $contents = preg_replace("/\x85/", "...", $contents);
            $contents = preg_replace("/\xBA/", "", $contents);

            file_put_contents($value, $contents);

        }

    }

}

Here is the error I’m trying to fix: Warning: simplexml_load_file() [function.simplexml-load-file]: ./04R_P455_S1157.xml:5: parser error : Input is not proper UTF-8, indicate encoding ! Bytes: 0x97 0x0D 0x0A 0x69 in C:\xampp\htdocs\hint_updater\libraries\hint_updater_classes.php on line 130

Still no luck, I’ve tried everything suggested in this thread, but the preg_replace doesn’t appear to be replacing all instances of hex code.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T06:42:42+00:00Added an answer on May 16, 2026 at 6:42 am

    You should first read the preg_replace docs. They clearly state that the function returns the modified string, so you will have to change every preg_replace line in your code by $contents = preg_replace(...); to make your replaces work. Right now you’re doing the replace but throwing the resulting string away, and thus in the end you write the original string back to the file.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an array randomAlphabets which contains CCSprite objects. I need to start animation
I have an array randomAlphabets which contains CCSprite objects. I need to start animation
I have a start of a webapp that I wrote without using the Object
I have a Perl hash whose keys start with, or are, numbers. If I
I have a scenario when I start 3..10 threads with ThreadPool. Each thread does
I have an .exe I want to start when the Win2k3 server boots. Does
I have a series of ranges with start dates and end dates. I want
I have a project that I would like to start beta testing soon, it
I have a file in the following format: Data Data Data [Start] Data I
I have a simple WPF application which I am trying to start. I am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.