ElMassimo / iles

🏝 The joyful site generator
https://iles.pages.dev
MIT License
1.08k stars 31 forks source link

The CJK content in the feed file generated is incorrectly encoded #100

Closed kecrily closed 2 years ago

kecrily commented 2 years ago

Description πŸ“–

Provide a clear and concise description of what the bug is.

The CJK content in the feed file generated is incorrectly encoded. It opens locally without problems, but looks like a bunch of mess in the web

image

Reproduction 🐞

Please provide a link to a repo that can reproduce the problem you ran into.

Write something CJK content, like δ½ ε₯½δΈ–η•Œ, then run pnpm build

Dependencies Info _Run `npx iles info` and `pnpm list` (or `npm list`) and provide the output:_ ``` devDependencies: @iconify/json 2.1.10 @vueuse/core 7.7.0 @islands/feed 0.1.2 dayjs 1.10.8 @islands/icons 0.1.1 iles 0.7.32 @islands/prism 0.1.1 typescript 4.6.2 @unocss/preset-typography 0.26.4 unocss 0.26.4 @unocss/transformer-directives 0.26.4 vue-tsc 0.32.1 ```

Logs πŸ“œ

If not providing a reproduction:

Output _Run `DEBUG=iles:* npm run dev` or `DEBUG=iles:* npm run build` and provide the output:_ ``` ```

Screenshots πŸ“·

Provide console or browser screenshots of the problem.

ElMassimo commented 2 years ago

Hi @kecrily!

I'm not familiar with CJK. How should it be encoded?

By default the generated XML specifies utf-8.

kecrily commented 2 years ago

The browser incorrectly uses GBK (a Chinese encoding) to parse the Chinese content, which uses UTF-8, so it is garbled.

By default the generated XML specifies utf-8.

Yes, but the browser does use GBK. I'm not sure why the browser automatically uses GBK to parse it.

ElMassimo commented 2 years ago

Did you try adding the site to feedly and see if the content is parsed as expected?

kecrily commented 2 years ago

I have no problem opening feed.atom directly from the absolute address. But when I open it through pnpm preview server, the encoding is wrong.

I'm guessing it's a Vite problem.

kecrily commented 2 years ago

Did you try adding the site to feedly and see if the content is parsed as expected?

Everything is fine.

ElMassimo commented 2 years ago

Gotcha, seems like it could be related to the headers (or lack of headers) provided to the browser by the Vite preview server.

It wouldn't affect the final result in production. Closing this one for now, but perhaps you can search in the Vite issue tracker to see if anyone has run into something similar in the past.