有誰知道為什麼 Curly Qoutes u2018 前後會有空白嗎?

紅寶鐵軌客
Join to follow...
Follow/Unfollow Writer: 紅寶鐵軌客
By following, you’ll receive notifications when this author publishes new articles.
Don't wait! Sign up to follow this writer.
WriterShelf is a privacy-oriented writing platform. Unleash the power of your voice. It's free!
Sign up. Join WriterShelf now! Already a member. Login to WriterShelf.
寫程式中、折磨中、享受中 ......
624   0  
·
2017/10/30
·
2 mins read


Unicode u2018 跟 u2019,也就是英文稱為 Smart Quotes 或是 Curly Qoutes 的 ‘  ’ 一對寶,這是個很神奇的字符,當在特定狀況時,瀏覽器會在前或後面自己加“空白”,而且有問題的話,問題會發生在英文版作業系統中,而中文版不會有問題,我找了好久,在網路上都找不到答案,很多前端工程師前輩都有發現這個問題,有些人的解法就乾脆就把這兩個字元取代成 straight quote ,我不覺得這是一個好的解法,畢竟,這對“寶”在英文使用上,是有一定重要性的。

"This is a 'magic' book."

vs.

“That’s a ‘magic’ book.”

在英文的寫法中,下面用 curly quotes 才是正確的寫法,也好看多了。

在一陣亂試中,我發現這問題可跟 font 的設定有關,當它在以下的 font-family 下,它的前後面會有一個空白:

font-family: "Lucida Grande", "Songti TC", "Microsoft JhengHei", PMingliu, 新細明體, sans-serif;

可以看到 Curly Quotes 的前後有空白

 

但是,把 font-family 設成這樣,也就是在中文字型前,加一個很常用的英文字型,就不會了:

font-family: "Lucida Grande", Helvetica, "Songti TC", "Microsoft JhengHei", PMingliu, 新細明體, sans-serif;

Curly Quotes 的前後沒空白了

合理的猜測是當英文字型找不到時,瀏覽器開始用下一個指定的字體,而下一個如果是中文,在英文版的電腦環境中,就會有空白產生,但是為什麼呢?

看起來跟中文字體有很大的關係,但是到底是為什麼?是不是有能人能教導一下,先感謝了。


WriterShelf™ is a unique multiple pen name blogging and forum platform. Protect relationships and your privacy. Take your writing in new directions. ** Join WriterShelf**
WriterShelf™ is an open writing platform. The views, information and opinions in this article are those of the author.


Article info

Categories:
Tags:
Total: 421 words


Share this article:
About the Author

很久以前就是個「寫程式的」,其實,什麼程式都不熟⋯⋯
就,這會一點點,那會一點點⋯⋯




Join the discussion now!
Don't wait! Sign up to join the discussion.
WriterShelf is a privacy-oriented writing platform. Unleash the power of your voice. It's free!
Sign up. Join WriterShelf now! Already a member. Login to WriterShelf.