→ shihyuyao:editor 是什麼編碼是指說我存檔時候選擇的檔案編碼嗎? 12/19 23:20
→ sbrhsieh:這是一種方式。不同 editor 的做法不同。 12/19 23:26
→ shihyuyao:有個疑問editor 是使用 big5 編碼那u"哈囉"還是big5編譯 12/20 23:55
→ shihyuyao:那加上 u還有什麼作用嗎? 12/20 23:55
→ sbrhsieh:有 leading u 是 unicode literal。 12/21 01:17
editor 產出 source file,檔案裡所有的文字都是使用特定的編碼,但因為所
使用的 keyword/identifier 都是英數字,這幾乎在每一種編碼裡的值都與 ASCII
相同,所以 editor 使用何種編碼影響都不大(除了有 BOM 的 encoding)。
但對於 str/unicode literal 內要使用非英數字元的情況下就需要注意。
在檔案中實際上界於 str/unicode literal 的兩個 " 中的 data 由 editor 使用
的 encoding 來決定(雖然在視覺上你在 editor 中看到的字元是一樣的在不同的
編碼下)。
在 compile 這樣的 expression 時:
u"..."
可以看成是在 compile-time/load-time 去 evaluate:
unicode("...", ENCODING, "strict")
而這個 ENCODING 可以由檔頭的 coding directive(註解)來變更。
※ 編輯: sbrhsieh 來自: 118.166.238.27 (12/21 01:31)
※ 編輯: sbrhsieh 來自: 118.166.238.27 (12/21 01:56)