Skip to content

How to specify charset? #24

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
dw9694 opened this issue Sep 22, 2021 · 2 comments
Open

How to specify charset? #24

dw9694 opened this issue Sep 22, 2021 · 2 comments

Comments

@dw9694
Copy link

dw9694 commented Sep 22, 2021

Hi. How to specify charset?

$ cat /tmp/index.html | htmlq 'title'
<title>������</title>
$ cat /tmp/index.html | htmlq 'h1.maintitle'
<h1 class="maintitle">������</h1>
@mgdm
Copy link
Owner

mgdm commented Jan 3, 2022

There's no way to do that right now as it pretty much assumes UTF-8 at the moment, but I'll have a look into it.

@Sematre
Copy link

Sematre commented Jan 11, 2022

I would pipe it through iconv --from-code <your_charset>.

Example: If your file is encoded with windows-1252, you can fix it like that:
cat /tmp/index.html | iconv --from-code windows-1252 | htmlq 'title'

Or even simpler: If you want to read from a file directly:
iconv --from-code windows-1252 /tmp/index.html | htmlq 'title'

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

3 participants