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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:57:44+00:00 2026-06-17T20:57:44+00:00

I need to read a file which is encoded with ISO-8859-1 (also called latin1),

  • 0

I need to read a file which is encoded with ISO-8859-1 (also called latin1), something like this:

var file_contents = fs.readFileSync("test_data.html", "latin1");

However, Node complains about “latin1” or “ISO-8859-1” not being a valid encoding (“Error: Unknown encoding”).

What encodings does readFileSync accept?

  • 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-17T20:57:45+00:00Added an answer on June 17, 2026 at 8:57 pm

    The list of encodings that node supports natively is rather short:

    • ascii
    • base64
    • base64url (Node v14+)
    • hex
    • ucs2/ucs-2/utf16le/utf-16le
    • utf8/utf-8
    • binary/latin1 (ISO8859-1, latin1 only in node 6.4.0+)

    If you are using an older version than 6.4.0, or don’t want to deal with non-Unicode encodings, you can recode the string:

    Use iconv-lite to recode files:

    var iconvlite = require('iconv-lite');
    var fs = require('fs');
    
    function readFileSync_encoding(filename, encoding) {
        var content = fs.readFileSync(filename);
        return iconvlite.decode(content, encoding);
    }
    

    Alternatively, use iconv:

    var Iconv = require('iconv').Iconv;
    var fs = require('fs');
    
    function readFileSync_encoding(filename, encoding) {
        var content = fs.readFileSync(filename);
        var iconv = new Iconv(encoding, 'UTF-8');
        var buffer = iconv.convert(content);
        return buffer.toString('utf8');
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to read in an Intel Hex file which looks something like this:
I have this file which I need to read the first bytes to check
I have a file which has text like this: #1#14#ADEADE#CAH0F#0#0..... I need to create
I need to read a BufferedImage from file, which doesn't use DataBufferInt (as normally),
I have a data file, which I need to read. I know to read
I have a flat CSV file which I need read from to end up
I have this resource file which I need to process, wich packs a set
Hi I've an excel file which looks like this id name age phne no
I need to read a CSV file which has fields that have a comma,
hi i need to read excel file which is stored in s3 server,i tried

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.