Skip to content
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

.textlintrc should be encoded as UTF-8 #298

Open
azu opened this issue May 25, 2017 · 19 comments · Fixed by #397
Open

.textlintrc should be encoded as UTF-8 #298

azu opened this issue May 25, 2017 · 19 comments · Fixed by #397
Labels
good first issue Good for newcomers Status: PR Welcome Welcome to Pull Request Status: Proposal Request for comments

Comments

@azu
Copy link
Member

azu commented May 25, 2017

Currently, textlint throw error when .textlintrc file is encoded as Shift-JIS.
We should check that the .textlintrc is UTF-8.

Proposal

If .textlintrc is not encoded by UTF-8, show error mesage in console.

Modules

Edit: Re-open by #509

@azu azu added good first issue Good for newcomers Status: Proposal Request for comments Status: Ready for PR labels May 25, 2017
@azu
Copy link
Member Author

azu commented Aug 5, 2017

@azu
Copy link
Member Author

azu commented Oct 12, 2017

@azu
Copy link
Member Author

azu commented Oct 14, 2017

@Leko
Copy link
Member

Leko commented Dec 15, 2017

I think utf-8-validate would be better.
I try it on Node.js v4.8.7, it works expected.

> node -e "console.log(require('utf-8-validate')(require('fs').readFileSync('utf8.txt')))"
true
> node -e "console.log(require('utf-8-validate')(require('fs').readFileSync('sjis.txt')))"
false

@Leko
Copy link
Member

Leko commented Dec 15, 2017

Currently, textlint throw error when .textlintrc file is encoded as Shift-JIS.

@azu How do I reproduce it ?

I try to reproduce on my blog( https://github.com/Leko/WEB-EGG ).

  1. clone this repo
  2. Run npm i
  3. Convert .textlintrc to Shift-JIS
  4. Run npm run lint:md

It does not throw an error.
But max-kanji-continuous-len.allow not working.
If .textlintrc encoded as UTF8, it works fine.

My .textlintrc is here: https://github.com/Leko/WEB-EGG/blob/master/.textlintrc#L17

@azu
Copy link
Member Author

azu commented Dec 15, 2017

This issue is based on bug report on twitter.

textlint use rc-loader in days past.
But, I've replaced it to rc-config-loader #39 #262

Maybe, "throwing error" is caused by rc-loader?

@Leko
Copy link
Member

Leko commented Dec 15, 2017

Hmm...
It doesn't throw error even in rc-loader@1.0.0.

screen shot 2017-12-16 at 0 37 09

We can close this issue ?

@azu
Copy link
Member Author

azu commented Dec 15, 2017

https://github.com/textlint-ja/textlint-rule-preset-JTF-style/blob/master/src/index.js
JTF preset use multibyte string in the key.
Is it a reason?

It does not throw an error.
But max-kanji-continuous-len.allow not working.

It is better that assert this. Silent failing make user confuse.
Bacause, It is not expeceted bahavior for user.

@azu
Copy link
Member Author

azu commented Dec 15, 2017

I love loud error rather than silent error.

@Leko
Copy link
Member

Leko commented Dec 15, 2017

max-kanji-continuous-len.allow not working.

In this case, if assert .textlintrc encoded as UTF8, markdown should be UTF8.
textlint can support text files encoded as UTF8 only.
It's OK ?

BTW, rc-loader throws error in https://github.com/textlint-ja/textlint-rule-preset-JTF-style/blob/master/src/index.js .

2017/12/16 1:16
I tested this JSON. src/index.js is javascript so I update as JSON.
https://gist.github.com/Leko/c937dbc2d9cdf451fc3595531e99b2da

screen shot 2017-12-16 at 0 48 25

@Leko
Copy link
Member

Leko commented Dec 15, 2017

I love loud error rather than silent error.

I think so too.

@azu
Copy link
Member Author

azu commented Dec 15, 2017

textlint can support text files encoded as UTF8 only.

Yes.
it looks good that implement the assertion in config-loader.

@Leko
Copy link
Member

Leko commented Dec 16, 2017

I got it.
I'll try to fix it :)

@azu
Copy link
Member Author

azu commented May 20, 2018

micnic/uv: Ultrafast UTF-8 data validation looks like good.
require Node.js 6+.

But, we can drop Node.js 4 support in near future #443

@azu
Copy link
Member Author

azu commented May 20, 2018

@azu
Copy link
Member Author

azu commented Dec 29, 2022

Next Node.js will introduce utf8 checker
nodejs/node#45947

@azu
Copy link
Member Author

azu commented Jan 30, 2024

buffer.isUtf8(input) require Node.js v18.14.0.

textlint 14 treat Node.js 18.14 as the minimal version.

@azu azu mentioned this issue Jan 30, 2024
8 tasks
@azu azu added the Status: PR Welcome Welcome to Pull Request label Feb 4, 2024
@JayC561
Copy link

JayC561 commented Sep 4, 2024

Hey @azu , is this issue closed or are we still looking for solutions?

@azu
Copy link
Member Author

azu commented Sep 4, 2024

#298 (comment)
is not implemented yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers Status: PR Welcome Welcome to Pull Request Status: Proposal Request for comments
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants