Skip to content

How to add utf8 read option for the Fs.readFileSync? #53

@wontheone1

Description

@wontheone1

It seems to me, from the way readFileSync binding is done, I cannot provide "utf8" option yet.
Could someone confirm it?

readFileOptions defined as,
https://github.com/sikanhe/reason-nodejs/blob/master/src/Fs.re#L203-L204

Flag defined as,
https://github.com/sikanhe/reason-nodejs/blob/master/src/Fs.re#L140-L189

I need to give utf8 to read text files properly as in NodeJs example:
https://nodejs.dev/learn/reading-files-with-nodejs

Looks to me, I should add something like the following to the definition of Flag.

...
  [@bs.inline "utf8"]
  let utf8: t;
...
  [@bs.inline "utf8"]
  let utf8 = "utf8";
...

But I am not 100 % sure (because I am Reason beginner still). Should I make PR with the above code change or could the library maintainers add utf8 flag for readFileSync function?

Thank you :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions