You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
URL with CJK characters becomes broken when exporting Typst document to PDF #6128
I have installed Typst-CLI on my Mac and am using the TinyMist extension in VSCode. When I use #link with a URL containing CJK characters, it seems that the URL becomes broken after exporting the document to PDF (it works fine when previewed in VSCode).
I’m not very knowledgeable about URL encoding, so I can’t explain it in detail, but I suspect that the issue lies in the process of converting non-ASCII URLs to ASCII, which seems to be handled differently than in a web browser.
VS Code is an Electron app, which uses Chromium. I guess that is why ok in VS Code.
on my Mac
Which PDF viewer do you use? Safari/Quartz? (Update: Yes I can reproduce it in Safari. Might be related to claudiodangelis/qrcp#331.)
Could you try to open the exported PDF in VS Code and see if the link is decoded correctly?
PS. Most LLMs are capable of decoding.
Reply to Please decode this…
The given string appears to be URL-encoded multiple times, likely due to improper encoding/decoding. Let's decode it step by step:
Under normal circumstances, the only time when octets within a URI
are percent-encoded is during the process of producing the URI from
its component parts. This is when an implementation determines which
of the reserved characters are to be used as subcomponent delimiters
and which can be safely used as data. Once produced, a URI is always
in its percent-encoded form.
An absolute URI, for these purposes, consists of a scheme followed by a colon (:) followed by zero or more characters other than ASCII control characters, space, <, and >. If the URI includes these characters, they must be percent-encoded (e.g. %20 for a space).
Activity
PartyWumpus commentedon Apr 1, 2025
Looks to me like something in typst is reinterpreting UTF-8 bytes as latin-1 (8 hit ASCII).
YDX-2147483647 commentedon Apr 1, 2025
I cannot reproduce your issue with the following document in Sumatra PDF, Chromium or Firefox.
VS Code is an Electron app, which uses Chromium. I guess that is why ok in VS Code.
Which PDF viewer do you use? Safari/Quartz? (Update: Yes I can reproduce it in Safari. Might be related to claudiodangelis/qrcp#331.)
Could you try to open the exported PDF in VS Code and see if the link is decoded correctly?
PS. Most LLMs are capable of decoding.
Reply to Please decode this…
The given string appears to be URL-encoded multiple times, likely due to improper encoding/decoding. Let's decode it step by step:
Step 1: First URL Decoding
Decoding
%C3%AB%C2%B2%C5%81...(UTF-8 encoded bytes) once:(This is still garbled because it was encoded multiple times.)
Step 2: Second URL Decoding
Decoding the result again:
(Now we see Korean characters encoded in UTF-8.)
Step 3: Final Decoding (Korean Text)
Decoding
%EB%B2%8C%EB%AC%B8...gives:(This translates to: "Legal Text / Health Regulations / Third Party")
Final Decoded URL (for
law.go.kr)The full decoded path is likely:
(This appears to be a Korean legal document related to health regulations, specifically about a "third party.")
Why This Happened
• The URL was double-encoded (UTF-8 bytes were URL-encoded twice).
• This often occurs when encoding is improperly handled in web requests.
Would you like help finding the actual law on
law.go.kr? Let me know!Enivex commentedon Apr 1, 2025
More importantly, the preview is not PDF based
docs: add several issues
docs: add several issues
YDX-2147483647 commentedon Aug 5, 2025
This issue can be mitigated by
http(s):and contains non-ASCII characters (e.g., with thenormalizefunction provided by rust-url or the lure package), andfile:.Links in bibliography should also share this feature.
I did a preliminary investigation on where to implement it.
Note
Edit: Discord, 2025-08-05
Maybe the
AsciiCharascii::Charin nightly rust? rust-lang/rust#110998Current status
typst will not encode any URL when exporting to html or pdf.
Example
krilla's API is
Stringhere, and the string will be serialized as raw bytes, without percent encoding.hayagriva will automatically encode URLs, even when displaying.
Spec
In short, non-ASCII strings are not valid URIs, but they are easier for human to understand.
PDF spec — ISO 32000-2:2020(E)
Table 210 Additional entries specific to a URI action, in Section 12.6.4.8 URI actions:
Screenshot
URI spec — RFC 3986
2.3. Unreserved Characters:
2.4. When to Encode or Decode:
Unicode tech standard —
Proposed DraftUTS #58: Unicode Link Detection andSerializationFormattingThis draft standard describes a Minimal Escaping Algorithm.
Update on 2026-04-22: The draft becomes a Unicode 17.0 standard on 2026-02-02.
CommonMark Spec
Reference implementation
mdbook and pulldown-cmark: Encode automatically
pulldown-cmark 0.13.0 (latest) and 0.9.6 (used by
main) will turn the above markdown into the following html.Rust test code
pandoc: Never encode
pandoc 3.5 does not encode when converting from the above markdown to html5 or pdf.
The behaviour is basically the same as typst 0.13.1, and suffers the same issue on Safari.
LaTeX and hyperref: Never encode
The behaviour is basically the same as typst 0.13.1, and suffers the same issue on Safari.
However, biblatex automatically encodes URLs, even when displaying. Its behaviour is the same as hayagriva.
squan3337-eng commentedon Dec 18, 2025