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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:44:59+00:00 2026-05-16T18:44:59+00:00

I have some files on my computer that are in UTF-16, though this seems

  • 0

I have some files on my computer that are in UTF-16, though this seems to be because of errors or corruption of the files rather than intent – they’re supposed to be plain english. I uploaded one of these (here). If I leave the encoding in Firefox (Viwe>Character Encoding) at UTF-8 then I get tons of gibberish (see screenshot). If I change the encoding to UTF-16 then it looks much better (see screenshot2), though there are still a bunch of CJK characters present.

I’d like to go through all these files and clean them up, and probably save them in utf-8 format (I’ll be inserting the contents into a mysql table that uses the utf8_general_ci collation). Does anyone know how I can do this in automated fashion with PHP? I’d like to get rid of all the funky characters the file displays if you try to view it in UTF-8, and also all the CJK characters the display if you view in UTF-16.

  • 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-16T18:44:59+00:00Added an answer on May 16, 2026 at 6:44 pm

    This should do the trick:

    $txt = file_get_contents('watches.txt');
    $txt = mb_convert_encoding($txt, 'UTF-8');
    /*Nice regexp to strip non asci and non-printable chars*/
    $txt = preg_replace('/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]+/S','',$txt);
    $txt = preg_replace('/[^\x00-\x7F]+/S','',$txt);
    
    echo $txt;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a file on my computer that I wanted to copy into a
I have some png's that are now resources in XCode. I would like to
I have a browser helper object on IE that have some clipboard history functions.
I am trying to get some files from a mounted read-only disk on a
I am running Aprelium Abyss Web Server from my home computer and I have
I have a Python script that does something along the line of: def MyScript(input_filename1,
I have svn repository with project on it. Right now there is good version
I am recompiling a old Delphi program (from Delphi 2007) in (Delphi 2010). The
I installed Coldfusion 8 trial version on my system (XP Professional sp3). I created

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.