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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:47:52+00:00 2026-05-27T00:47:52+00:00

I have a file in Unicode format on a windows machine. Is there any

  • 0

I have a file in Unicode format on a windows machine. Is there any way to convert it to ASCII format on a windows machine using perl script

It’s UTF-16 BOM.

  • 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-27T00:47:52+00:00Added an answer on May 27, 2026 at 12:47 am

    If you want to convert unicode to ascii, you must be aware that some characters can’t be converted, because they just don’t exist in ascii.
    If you can live with that, you can try this:

    #!/usr/bin/env perl
    use strict;
    use warnings;
    use autodie;
    
    use open IN => ':encoding(UTF-16)';
    use open OUT => ':encoding(ascii)';
    
    my $buffer;
    
    open(my $ifh, '<', 'utf16bom.txt');
    read($ifh, $buffer, -s $ifh);
    close($ifh);
    
    open(my $ofh, '>', 'ascii.txt');
    print($ofh $buffer);
    close($ofh);
    

    If you do not have autodie, just remove that line – you should then change your open/close statements with a

    open(...) or die "error: $!\n";
    

    If you have characters that can’t be converted, you will get warnings on the console and your output file will have e.g. text like

    \x{00e4}\x{00f6}\x{00fc}\x{00df}
    

    in it.
    BTW: If you don’t have a mom but know it is Big Endian (Little Endian), you can change the encoding line to

    use open IN => ':encoding(UTF-16BE)';
    

    or

    use open IN => ':encoding(UTF-16LE)';
    

    Hope it works under Windows as well. I can’t give it a try right now.

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

Sidebar

Related Questions

I have a Unicode file (UTF-16 FFFE little-endian BOM) which contains rows of tab-separated
I'm having trouble reading in supplementary unicode characters using Java. I have a file
On OS-X (PHP5.2.11) I have a file: siësta.doc (and thousand other with Unicode filenames)
If i have file for eg: a log file created by any background process
I have a file in the following format: Data Data Data [Start] Data I
I have Windows File sharing enabled on an OS X 10.4 computer. It's accessible
I have a file containing Unicode characters on a server running linux. If I
I have a problem reading and using the content from unicode files. I am
I use a 3rd party tool that outputs a file in Unicode format. However,
I have a file saved as UTF-8, and i'm reading it like this: ReadFile(hFile,

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.