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 8477965
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:36:48+00:00 2026-06-10T18:36:48+00:00

I’m having a real nightmare parsing data from one database where much of the

  • 0

I’m having a real nightmare parsing data from one database where much of the text has been pasted from Word across into another database. The data needs to be washed through the parser each day so it isn’t just a matter of cleaning up the source data once.

The trouble is that the target keeps moving as it gets processed and I’m getting very mixed results.

The process basically is to copy exported SQL generated from PHPMyAdmin; paste this into a form and then run the parsing script; the script then saves the ‘cleaned’ data into a different database.

A sample of what is in the data includes stuff like…

Comply with “Regulations�

Where ideally this would be…

Comply with "Regulations"

By the time all the parsing is done and stored in the new database I’m left with…

Comply with AS3868 â€Å"Regulationsâ€Â

There are other Word characters such as elipsis etc but this example just shows the smart-quotes.

What is the best way for me to clean the data once it is posted through via a form?

  • 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-06-10T18:36:50+00:00Added an answer on June 10, 2026 at 6:36 pm

    This one ended up being much more of a pain to solve than it sounds as though it should have been. Essentially the data was corrupting through various processes where there wasn’t a clearly defined encoding environment. Essentially the data was double-encoding as it was parsed so that “ became “ and then became “

    This thread helped enormously with understanding the environmental issues and how to make sure PHP, MySQL and my coding environment were all using UTF-8 as its defaults.

    This site was great with testing and fixing the mysql environment. The code from that page worked well on the server (accessed and changed using SSL). I use a WAMP server locally and the code didn’t work well there. I ended up making the following changes to my my.ini file

    [client]
    ...
    default-character-set=utf8
    
    [wampmysqld]
    ...
    character-set-server=utf8
    collation-server=utf8_general_ci
    init-connect='SET NAMES utf8'
    

    Then I needed to fix the data that was there.

    I was going to just replace the offending code with safe single-byte characters (“ would be “) but in the end I decided to just make sure the multi-byte characters were corrected so that they displayed when viewed as UTF-8.

    I didn’t want to trust a script to encode the search and replace strings and I found a great starting point here. I used MySQL’s UNHEX function to control this aspect:

    -- Single quotes
    UPDATE table SET column = REPLACE(column, UNHEX('C3A2E282ACCB9C'), UNHEX('E28098'));
    UPDATE table SET column = REPLACE(column, UNHEX('C3A2E282ACE284A2'), UNHEX('E28099'));
    -- Double quotes
    UPDATE table SET column = REPLACE(column, UNHEX('C3A2E282ACC593'), UNHEX('E2809C'));
    UPDATE table SET column = REPLACE(column, UNHEX('C3A2E282ACC29D'), UNHEX('E2809D'));
    -- Em and En dashes
    UPDATE table SET column = REPLACE(column, UNHEX('C3A2E282ACE2809C'), UNHEX('E28094'));
    UPDATE table SET column = REPLACE(column, UNHEX('C3A2E282ACE2809D'), UNHEX('E28094'));
    

    To make sure everything was working, I took a copy of the table and then replaced all of the changed multi-byte characters to single characters

    UPDATE table SET column = REPLACE(column, UNHEX('E28098'), "'");
    UPDATE table SET column = REPLACE(column, UNHEX('E28099'), "'");
    UPDATE table SET column = REPLACE(column, UNHEX('E2809C'), '"');
    UPDATE table SET column = REPLACE(column, UNHEX('E2809D'), '"');
    UPDATE table SET column = REPLACE(column, UNHEX('E28093'), '-');
    UPDATE table SET column = REPLACE(column, UNHEX('E28094'), '-');
    

    and then ran this MySQL script to capture any records that still contained multi-byte characters:

    SELECT * FROM table WHERE LENGTH(column) != CHAR_LENGTH(column);
    

    This was I was able to quickly hunt down the anomalies in the existing data.

    Hope this helps anyone else trying to transfer data across different systems.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a text area in my form which accepts all possible characters from
I have a reasonable size flat file database of text documents mostly saved in
I have a view passing on information from a database: def serve_article(request, id): served_article
I have a bunch of posts stored in text files formatted in yaml/textile (from
I want to count how many characters a certain string has in PHP, but
I have a jquery bug and I've been looking for hours now, I can't

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.