QL-Win / QL-Win/QuickLook

Markdown file charset detection issue

Open
#877 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
24.7k
Forks
1.3k
Avg merge
4d 7h
Merged PRs (30d)
1

Description

Describe the bug

It seems that the charset detection implementation at L72 of Plugin.cs of the MarkdownViewer plugin would return incorrect file encoding for UTF-8 files without the BOM, and ultimately causing the rendering of markdown files to display corrupted characters for unicode characters, as shown in the image below (The file is the README.md file of this project). However, I do notice that if the majority content of the file is not written in characters in the ASCII range (e.g. in Chinese), the file will be rendered correctly even the encoding is UTF-8 without BOM, so I'm not sure whether it's about the charset detection part or the Encoding.Default part.

Also, related issue #758.

To Reproduce

  1. Use QuickLook to preview a markdown file encoded in UTF-8 without the BOM
    corrupted markdown rendering

  2. If I save the file in UTF-8 with BOM:
    convert the encoding to UTF-8 with BOM
    The rendering is normal:
    normal markdown rendering

Expected behavior

Given that "The Unicode Standard neither requires nor recommends the use of the BOM for UTF-8", UTF-8 encoded text files without the BOM should be read correctly.

Desktop Environment

  • OS Version: Windows 10 1709
  • QuickLook Version: 3.6.11

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at line 72 of QuickLook.Plugin/QuickLook.Plugin.MarkdownViewer/Plugin.cs and inspect the MarkdownViewer charset detection and Encoding.Default behavior. Reproduce the issue with the project's README.md saved as UTF-8 without a BOM, then verify that Unicode characters render correctly without requiring a BOM.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
desktop
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.