GithubHelp home page GithubHelp logo

Comments (7)

KaKi87 avatar KaKi87 commented on June 15, 2024 1

Thanks !

from detect-character-encoding.

sonicdoe avatar sonicdoe commented on June 15, 2024

Are you looking to directly detect the encoding of a variable or to directly convert a string to UTF-8? As for the latter, I’m not sure how detect-character-encoding can be of much help.

from detect-character-encoding.

sonicdoe avatar sonicdoe commented on June 15, 2024

Closing due to lack of response.

from detect-character-encoding.

KaKi87 avatar KaKi87 commented on June 15, 2024

Hey,
I wanted to do both, and it would have been great if your module could do the first thing, but I was actually downloading a file and the encoding was specified in the HTTP response header, I didn't knew it before I posted that issue.
Thanks !

from detect-character-encoding.

sonicdoe avatar sonicdoe commented on June 15, 2024

Using the HTTP header is definitely a better idea but just in case you might need it again: You can download a file to a Buffer which you can then directly pass to detect-character-encoding.

from detect-character-encoding.

KaKi87 avatar KaKi87 commented on June 15, 2024

The Buffer.from method takes encoding as second parameter, and it is default to UTF-8, but I don't know the encoding, and that's why I would like to use your library, then how could I pass a variable to Buffer without knowing the encoding and then detect it using your library ?
https://nodejs.org/api/buffer.html#buffer_class_method_buffer_from_string_encoding

from detect-character-encoding.

sonicdoe avatar sonicdoe commented on June 15, 2024

Buffer.from(array) accepts an array of octets which you could then pass to detect-character-encoding. If you’d like to download a file, though, various HTTP request libraries (such as Got) already support returning a Buffer.

from detect-character-encoding.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.