我有一段代码:
; 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
这很好,除了我无法找到一种方法,在脚本文件中,告诉 CLisp 我正在以 UTF-8 格式输入字符串,我希望它以 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)))
最佳答案
总结
要么
使用操作系统:
- Windows : How do I view and change the system locale settings to use my language of choice?
- Unix : How to change locale environment variable?
或
- 使用
-E UTF-8
command line argument 运行 CLISP (clisp.exe -E UTF-8/path/....
),或 - 设置default encodings在init file . 请注意,在您的 lisp 文件中设置这些变量inside 错误将没有帮助,因为在 CLISP 读取变量时,该文件已经以错误的外部格式打开。
CLISP FAQ: What do charset errors mean?
这意味着您正在尝试从具有 ASCII 的字符流中读取(“无效字节”)或写入(“字符无法表示”)非 ASCII 字符(或向其写入):EXTERNAL-FORMAT
. -Edomain encoding 中描述了默认值.
这也可能是由文件系统访问引起的。如果您的文件名称与您的 CUSTOM:*PATHNAME-ENCODING*
不兼容,文件系统访问(例如,DIRECTORY
)将SIGNAL
这个ERROR
。您需要设置 CUSTOM:*PATHNAME-ENCODING*
或将 -Edomain encoding
传递给 CLISP。使用“1:1”编码,例如 CHARSET:ISO-8859-1
,应该可以帮助您避免此错误。
请查看官方网站以获取完整文档。
附言。 You now owe me 10 zorkmids
PPS。你的代码 (list '(...) '(...) ...)
看起来很奇怪,你可能想用 '((...) (.. .) ...)
。我的意思是,你的作品也是,只是风格不好。
关于unicode - CLisp:将字符串编码设置为 UTF-8,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44184774/