princ tm 是乱码状态,即使txt里面写的是英文字母也乱码,TKS
(defun C:xwy( / tt f txt tm cl xx xk)
(setq f (open "C:\\jx.txt" "r"))
(read-line f )
(while (setq txt (read-line f))
       (setq tm (substr txt 1 20))
       (setq cl (substr txt 21 3))
       (setq xx (substr txt 29 10))
       (setq xk (substr txt 44 4))
  )
;;(command "_layer" "n" tm "c" cl tm "l" xx tm "lw" xk tm "") )
   (PRINC "图层加载OK")
  (princ tm)
  (princ "It's OK")
  )



网友答: 重新测试了,英文不乱码,中文乱码

网友答: 通常是由于文件编码不是 ascii 是 utf-8或其它类似的吧。记事本打开文件,“另存为” 编码选择 ascii,重新保存再试试。

网友答:
dunkel 发表于 2020-6-18 08:34
通常是由于文件编码不是 ascii 是 utf-8或其它类似的吧。记事本打开文件,“另存为” 编码选择 ascii,重新 ...

是编码问题,需要用GB2312
谢谢答复

网友答:
slysmart 发表于 2020-6-18 15:42
是编码问题,需要用GB2312
谢谢答复

新的 2021 版默认使用 utf8了,且open函数增加了编码的参数。

另外,通过txt等外部文件记录与读取数据,不要用这种笨办法,应该参考更加可靠的关键字key与值value的方式,例如ini,cfg这样的格式。


网友答:
e2002 发表于 2020-10-8 11:00
新的 2021 版默认使用 utf8了,且open函数增加了编码的参数。

另外,通过txt等外部文件记录与读取数据 ...

open函数增加了编码的参数,增加的参数是是什么?
  • 上一篇:块文字 如何求和?
  • 下一篇:没有了