2017-05-25 73 views
1

我有一些一段代碼:CLISP:集編碼爲UTF-8字符串

; Palatal Pulmonic Consonants 
(loop for e in (list 
        '(:nasal "ɲ") 
        '(:plosive "c") '(:plosive "ɟ") 
        '(:fricative "ç") '(:fricative "ʝ") 
        '(:approximant "j") 
        '(:lateral-fricative "ʎ̥˔") 
        '(:lateral-approximant "ʎ") 
        '(:lateral-flap "ʎ̯")) do 
    (add-sound :palatal (car e) (cadr e))) 

我有很多這些位爲所有IPA符號,這沒有特別的問題之一。

但是,試圖運行我的代碼給出了這樣的錯誤:

SYSTEM::STRING-READER: Invalid byte #x90 in CHARSET:CP1252 conversion

這很好,但我不能找到一個辦法,在腳本文件,告訴我在UTF-8中輸入字符串CLISP ,我希望它能夠讀取並以UTF-8格式打印出來。

如何在全局範圍內永久設置UTF-8。我在類似地考慮Ruby的# encoding: utf-8

特別是我使用CLisp 2.48。

編輯:

下面是完整的源文件列表導致問題:

(defstruct sound place means sym) 
(defparameter $sounds nil) 
(defun add-sound (place means sym) 
    (setf $sounds (append $sounds (list (make-sound :place place :means means :sym sym))))) 
; There are alot of IPA symbols, so we'll add them column by column. 
; The first column is the Bilabial Pulmonic Consonants 
(loop for e in (list 
        '(:nasal "m") '(:plosive "p") 
        '(:plosive "b") '(:fricative "ɸ") 
        '(:fricative "β") '(:trill "ʙ") 
        '(:flap "ⱱ̟")) do 
    (add-sound :bilabial (car e) (cadr e))) 
; Labiodental Pulmonic Consonants 
(loop for e in (list 
        '(:nasal "ɱ") '(:plosive "p̪") 
        '(:plosive "b̪") '(:fricative "f") 
        '(:fricative "v") '(:approximant "ʋ") 
        '(:flap "ⱱ")) do 
    (add-sound :labiodental (car e) (cadr e))) 
; Dental Pulmonic Consonants 
(loop for e in (list 
        '(:nasal "n̪") 
        '(:plosive "t̪") '(:plosive "d̪") 
        '(:fricative "θ") '(:fricative "ð")) do 
    (add-sound :dental (car e) (cadr e))) 
; Alveolar Pulmonic Consonants 
(loop for e in (list 
        '(:nasal "n") 
        '(:plosive "t") '(:plosive "d") 
        '(:fricative "s") '(:fricative "z") 
        '(:trill "r") 
        '(:flap "ɾ") 
        '(:lateral-fricative "ɬ") '(:lateral-fricative "ɮ") 
        '(:lateral-approximant "l") 
        '(:lateral-flap "ɺ")) do 
    (add-sound :alveolar (car e) (cadr e))) 
; Palato-Alveolar Pulmonic Consonants 
(loop for e in (list 
        '(:fricative "ʃ") '(:fricative "ʒ") 
        '(:approximant "ɹ")) do 
    (add-sound :palato-alveolar (car e) (cadr e))) 
; Retroflex Pulmonic Consonants 
(loop for e in (list 
        '(:nasal "ɳ") 
        '(:plosive "ʈ") '(:plosive "ɖ") 
        '(:fricative "ʂ") '(:fricative "ʐ") 
        '(:approximant "ɻ") 
        '(:trill "ɽ͡r") 
        '(:flap "ɽ") 
        '(:lateral-fricative "ɭ˔̊") 
        '(:lateral-approximant "ɭ") 
        '(:lateral-flap "ɺ̢")) do 
    (add-sound :retroflex (car e) (cadr e))) 
; Palatal Pulmonic Consonants 
(loop for e in (list 
        '(:nasal "ɲ") 
        '(:plosive "c") '(:plosive "ɟ") 
        '(:fricative "ç") '(:fricative "ʝ") 
        '(:approximant "j") 
        '(:lateral-fricative "ʎ̥˔") 
        '(:lateral-approximant "ʎ") 
        '(:lateral-flap "ʎ̯")) do 
    (add-sound :palatal (car e) (cadr e))) 
; Velar Pulmonic Consonants 
(loop for e in (list 
        '(:nasal "ŋ") 
        '(:plosive "k") '(:plosive "ɡ") 
        '(:fricative "x") '(:fricative "ɣ") 
        '(:approximant "ɰ") 
        '(:lateral-fricative "ʟ̝̊") 
        '(:lateral-approximant "ʟ")) do 
    (add-sound :velar (car e) (cadr e))) 
; Uvular Pulmonic Consonants 
(loop for e in (list 
        '(:nasal "ɴ") 
        '(:plosive "q") '(:plosive "ɢ") 
        '(:fricative "χ") '(:fricative "ʁ") 
        '(:trill "ʀ") 
        '(:flap "ɢ̆")) do 
    (add-sound :uvular (car e) (cadr e))) 
; Pharyngeal Pulmonic Consonants 
(loop for e in (list 
        '(:plosive "ʡ") 
        '(:fricative "ħ") '(:fricative "ʕ") 
        '(:trill "ʜ") '(:trill "ʢ") 
        '(:flap "ʡ̯")) do 
    (add-sound :pharyngeal (car e) (cadr e))) 
; Glottal Pulmonic Consonants 
(loop for e in (list 
        '(:plosive "ʔ") 
        '(:fricative "h") '(:fricative "ɦ")) do 
    (add-sound :glottal (car e) (cadr e))) 
+0

你究竟做了什麼來獲得錯誤? – sds

+0

我運行clisp.exe /path/to/file.lisp,其中該文件包含上述示例。我可以發佈更多的文件,但這並不是相關的。 –

+0

好,你可以在「clisp.exe」和「/ path/to/file.lisp」之間插入「-E UTF-8」來獲得clisp.exe -E UTF-8/path /到/ file.lisp'「? – sds

回答

3

摘要

要麼

CLISP FAQ: What do charset errors mean?

這意味着你想讀(「無效字節」)或寫(「字符無法表示」)從非ASCII字符(或)具有字符流ASCII :EXTERNAL-FORMAT。默認值在-Edomain encoding中描述。

這也可能是由文件系統訪問引起的。如果您的文件名稱與您的CUSTOM:*PATHNAME-ENCODING*不兼容,則文件系統訪問(例如,DIRECTORY)將爲SIGNALERROR。您需要設置CUSTOM:*PATHNAME-ENCODING*或將-Edomain encoding傳遞給CLISP。使用「1:1」編碼(如CHARSET:ISO-8859-1)應該可以幫助您避免此錯誤。

請參閱官方網站獲取完整文檔。

PS。 You now owe me 10 zorkmids

PPS。您的代碼(list '(...) '(...) ...)看起來很奇怪,您可能想用'((...) (...) ...)替換它。我的意思是,你的作品也只是不好的風格。

+0

我很欣賞這個答案,但我已經閱讀了所有這些東西。我很清楚爲什麼問題存在,我根本不知道如何解決問題。知道問題並知道如何精確地在Lisp中解決它,特別是不必使用-Edomain編碼,就會脫節。我也嘗試過使用各種CUSTOM:* BLAH-ENCODING *變量並設置它們,比如'(setf CUSTOM:* MISC-ENCODING *(make-encoding:charset charset:utf-8)) PS:你現在欠我6個zorkmids的信用來應用於迴應。 –

+0

我感謝你的時間和麻煩,但我明白了這一切。我根本不知道如何去做。這些文件沒有說明如何做,只有做什麼。有一個區別。 我的例子中,如何做到這一點的紅寶石是: 寫這行:#編碼UTF-8 是否有一個相當於線是Lisp的,如果那麼,什麼是線。不是這條線背後的概念,也不是它存在的方式或原因,而是它是什麼。 –

+0

是否有可以處理UTF-8輸入的公共Lisp的實現?我的意思是,腳本文件是否可以寫入,其中的字符串是硬編碼的,其中的字符串包含UTF-8字符?這不需要特殊的命令行參數? –