Skip to content

string.charCodeAt is not a function #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
bash0312 opened this issue Mar 4, 2017 · 4 comments
Open

string.charCodeAt is not a function #26

bash0312 opened this issue Mar 4, 2017 · 4 comments

Comments

@bash0312
Copy link

bash0312 commented Mar 4, 2017

TypeError: string.charCodeAt is not a function
    at ucs2decode (C:\Users\bash\NEMid\node_modules\utf8\utf8.js:30:19)
    at Object.utf8decode [as decode] (C:\Users\bash\NEMid\node_modules\utf8\utf8.js:201:15)
    at Object.<anonymous> (C:\Users\bash\NEMid\client.js:21:95)
    at Module._compile (module.js:573:32)
    at Object.Module._extensions..js (module.js:582:10)
    at Module.load (module.js:490:32)
    at tryModuleLoad (module.js:449:12)
    at Function.Module._load (module.js:441:3)
    at Module.runMain (module.js:607:10)
    at run (bootstrap_node.js:382:7)

node v7.0.0

@mathiasbynens
Copy link
Owner

mathiasbynens commented Mar 4, 2017

Are you passing undefined to utf8.decode()? If not, how can I reproduce this issue?

@hellais
Copy link

hellais commented Aug 13, 2017

I also encountered this error and was at first a bit confused, but then realised that it was happening because I was passing a Buffer instead of a "binary string". Maybe the docs can be made more explicit about the fact that Buffer are actually not supported at least not until #7 is solved.

@jmaister
Copy link

jmaister commented Aug 1, 2018

Reading the file with encoding set fixes this problem:

const input = fs.readFileSync('./thefile.txt', {encoding: 'utf8'});

@hellais
Copy link

hellais commented Aug 1, 2018

Reading the file with encoding set fixes this problem:
const input = fs.readFileSync('./thefile.txt', {encoding: 'utf8'});

If you are reading the file in that way, then you do not need this library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants