FAQ
How to detect if file is text or binary using Nodejs?


I need it to put file content in json and if file is text, I will use
encoding parameter in fs.readFile, and if the file is binary, I will read
it without encoding

--
Job Board: http://jobs.nodejs.org/
Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Search Discussions

  • Greelgorke at Jan 22, 2013 at 2:13 pm
    i guess only by try and error. if you want to put the content of the file
    to json, you will use encoding anyway, because json is a text format. so, i
    don't know what kind of data is in the files, but i would just use utf8 and
    see if anything comes out of it.

    Am Dienstag, 22. Januar 2013 11:54:14 UTC+1 schrieb Vladimir Starkov:
    How to detect if file is text or binary using Nodejs?


    I need it to put file content in json and if file is text, I will use
    encoding parameter in fs.readFile, and if the file is binary, I will read
    it without encoding
    --
    Job Board: http://jobs.nodejs.org/
    Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    You received this message because you are subscribed to the Google
    Groups "nodejs" group.
    To post to this group, send email to nodejs@googlegroups.com
    To unsubscribe from this group, send email to
    nodejs+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en
  • Greelgorke at Jan 22, 2013 at 2:14 pm
    may be this can help you
    too http://en.wikipedia.org/wiki/Byte_Order_Mark#Representations_of_byte_order_marks_by_encoding

    Am Dienstag, 22. Januar 2013 15:13:31 UTC+1 schrieb greelgorke:
    i guess only by try and error. if you want to put the content of the file
    to json, you will use encoding anyway, because json is a text format. so, i
    don't know what kind of data is in the files, but i would just use utf8 and
    see if anything comes out of it.

    Am Dienstag, 22. Januar 2013 11:54:14 UTC+1 schrieb Vladimir Starkov:
    How to detect if file is text or binary using Nodejs?


    I need it to put file content in json and if file is text, I will use
    encoding parameter in fs.readFile, and if the file is binary, I will read
    it without encoding
    --
    Job Board: http://jobs.nodejs.org/
    Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    You received this message because you are subscribed to the Google
    Groups "nodejs" group.
    To post to this group, send email to nodejs@googlegroups.com
    To unsubscribe from this group, send email to
    nodejs+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en
  • Nathan Rajlich at Jan 22, 2013 at 4:51 pm
    Perhaps try node-mmmagic: https://github.com/mscdex/mmmagic
    On Tue, Jan 22, 2013 at 6:14 AM, greelgorke wrote:

    may be this can help you too
    http://en.wikipedia.org/wiki/Byte_Order_Mark#Representations_of_byte_order_marks_by_encoding

    Am Dienstag, 22. Januar 2013 15:13:31 UTC+1 schrieb greelgorke:
    i guess only by try and error. if you want to put the content of the file
    to json, you will use encoding anyway, because json is a text format. so, i
    don't know what kind of data is in the files, but i would just use utf8 and
    see if anything comes out of it.

    Am Dienstag, 22. Januar 2013 11:54:14 UTC+1 schrieb Vladimir Starkov:
    How to detect if file is text or binary using Nodejs?


    I need it to put file content in json and if file is text, I will use
    encoding parameter in fs.readFile, and if the file is binary, I will read
    it without encoding
    --
    Job Board: http://jobs.nodejs.org/
    Posting guidelines:
    https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    You received this message because you are subscribed to the Google
    Groups "nodejs" group.
    To post to this group, send email to nodejs@googlegroups.com
    To unsubscribe from this group, send email to
    nodejs+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en
    --
    Job Board: http://jobs.nodejs.org/
    Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    You received this message because you are subscribed to the Google
    Groups "nodejs" group.
    To post to this group, send email to nodejs@googlegroups.com
    To unsubscribe from this group, send email to
    nodejs+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en
  • Greelgorke at Jan 23, 2013 at 8:37 am
    it's a kind of magic! cool thing

    Am Dienstag, 22. Januar 2013 17:51:19 UTC+1 schrieb Nathan Rajlich:
    Perhaps try node-mmmagic: https://github.com/mscdex/mmmagic

    On Tue, Jan 22, 2013 at 6:14 AM, greelgorke <greel...@gmail.com<javascript:>
    wrote:
    may be this can help you too
    http://en.wikipedia.org/wiki/Byte_Order_Mark#Representations_of_byte_order_marks_by_encoding

    Am Dienstag, 22. Januar 2013 15:13:31 UTC+1 schrieb greelgorke:
    i guess only by try and error. if you want to put the content of the
    file to json, you will use encoding anyway, because json is a text format.
    so, i don't know what kind of data is in the files, but i would just use
    utf8 and see if anything comes out of it.

    Am Dienstag, 22. Januar 2013 11:54:14 UTC+1 schrieb Vladimir Starkov:
    How to detect if file is text or binary using Nodejs?


    I need it to put file content in json and if file is text, I will use
    encoding parameter in fs.readFile, and if the file is binary, I will read
    it without encoding
    --
    Job Board: http://jobs.nodejs.org/
    Posting guidelines:
    https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    You received this message because you are subscribed to the Google
    Groups "nodejs" group.
    To post to this group, send email to nod...@googlegroups.com<javascript:>
    To unsubscribe from this group, send email to
    nodejs+un...@googlegroups.com <javascript:>
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en
    --
    Job Board: http://jobs.nodejs.org/
    Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    You received this message because you are subscribed to the Google
    Groups "nodejs" group.
    To post to this group, send email to nodejs@googlegroups.com
    To unsubscribe from this group, send email to
    nodejs+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en
  • Vladimir Starkov at Jan 28, 2013 at 6:54 am
    It’s not working on windows
    On Tuesday, 22 January 2013 21:51:19 UTC+5, Nathan Rajlich wrote:

    Perhaps try node-mmmagic: https://github.com/mscdex/mmmagic

    On Tue, Jan 22, 2013 at 6:14 AM, greelgorke <greel...@gmail.com<javascript:>
    wrote:
    may be this can help you too
    http://en.wikipedia.org/wiki/Byte_Order_Mark#Representations_of_byte_order_marks_by_encoding

    Am Dienstag, 22. Januar 2013 15:13:31 UTC+1 schrieb greelgorke:
    i guess only by try and error. if you want to put the content of the
    file to json, you will use encoding anyway, because json is a text format.
    so, i don't know what kind of data is in the files, but i would just use
    utf8 and see if anything comes out of it.

    Am Dienstag, 22. Januar 2013 11:54:14 UTC+1 schrieb Vladimir Starkov:
    How to detect if file is text or binary using Nodejs?


    I need it to put file content in json and if file is text, I will use
    encoding parameter in fs.readFile, and if the file is binary, I will read
    it without encoding
    --
    Job Board: http://jobs.nodejs.org/
    Posting guidelines:
    https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    You received this message because you are subscribed to the Google
    Groups "nodejs" group.
    To post to this group, send email to nod...@googlegroups.com<javascript:>
    To unsubscribe from this group, send email to
    nodejs+un...@googlegroups.com <javascript:>
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en
    --
    --
    Job Board: http://jobs.nodejs.org/
    Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    You received this message because you are subscribed to the Google
    Groups "nodejs" group.
    To post to this group, send email to nodejs@googlegroups.com
    To unsubscribe from this group, send email to
    nodejs+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en

    ---
    You received this message because you are subscribed to the Google Groups "nodejs" group.
    To unsubscribe from this group, send email to nodejs+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Mscdex at Jan 28, 2013 at 6:57 am

    On Jan 28, 1:54 am, Vladimir Starkov wrote:
    It’s not working on windows
    Can you elaborate? What errors (if any) are you getting?

    --
    --
    Job Board: http://jobs.nodejs.org/
    Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    You received this message because you are subscribed to the Google
    Groups "nodejs" group.
    To post to this group, send email to nodejs@googlegroups.com
    To unsubscribe from this group, send email to
    nodejs+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en

    ---
    You received this message because you are subscribed to the Google Groups "nodejs" group.
    To unsubscribe from this group, send email to nodejs+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Mscdex at Jan 28, 2013 at 7:04 am

    On Jan 28, 1:57 am, mscdex wrote:
    On Jan 28, 1:54 am, Vladimir Starkov wrote:

    It’s not working on windows
    Can you elaborate? What errors (if any) are you getting?
    Also, give the master branch a try: `npm install
    https://github.com/mscdex/mmmagic/tarball/master`

    --
    --
    Job Board: http://jobs.nodejs.org/
    Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    You received this message because you are subscribed to the Google
    Groups "nodejs" group.
    To post to this group, send email to nodejs@googlegroups.com
    To unsubscribe from this group, send email to
    nodejs+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en

    ---
    You received this message because you are subscribed to the Google Groups "nodejs" group.
    To unsubscribe from this group, send email to nodejs+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupnodejs @
categoriesnodejs
postedJan 22, '13 at 11:14a
activeJan 28, '13 at 7:04a
posts8
users4
websitenodejs.org
irc#node.js

People

Translate

site design / logo © 2022 Grokbase