明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
12
返回列表 发新帖
楼主: jaminth

申请编文字倒排列LISP程序

  [复制链接]
 楼主| 发表于 2007-7-8 14:08 | 显示全部楼层
再次改进!!谢谢谢谢
  1. (defun c:rrt ( / en_data i strl tmps txt txt_list txt_list2)
  2.   (setq en_data (entget (car (entsel "select:"))))
  3.   (setq txt_list (assoc 1 en_data))
  4.   (setq txt (cdr txt_list))
  5.   (setq strl (strlen txt)
  6. i    strl
  7. tmps ""
  8.   )
  9.   (while (> i 0)
  10.     (if (> (ascii (substr txt i 1)) 127)
  11.       (setq tmps (strcat tmps (substr txt (1- i) 2))
  12.      i  (- i 2)
  13.       )
  14.       (setq tmps (strcat tmps (substr txt i 1))
  15.      i  (1- i)
  16.       )
  17.     )
  18.   )
  19.   (setq txt_list2 (cons 1 tmps))
  20.   (setq en_data (subst txt_list2 txt_list en_data))
  21.   (entmod en_data)
  22.   (prin1)
  23. )
发表于 2007-7-9 22:02 | 显示全部楼层
调用VBScript中StrReverse函数可以方便地含有中文字符的倒序问题.
发表于 2007-7-10 07:57 | 显示全部楼层

给个例子

发表于 2007-7-10 13:21 | 显示全部楼层
本帖最后由 作者 于 2007-7-10 19:01:12 编辑

  1. ;;倒排字符串.by 无痕
  2. (defun revstr(str / lst a lst2)
  3.   (setq lst nil a nil lst2 nil)
  4.   (setq lst(vl-string->list str))
  5.   (while (setq a (car lst))
  6.     (if (> a 159)
  7.        (setq lst2 (cons (cadr lst) lst2)
  8.       lst2 (cons a lst2)
  9.       lst (cddr lst))
  10.        (setq lst2 (cons a lst2)
  11.       lst (cdr lst))
  12.     )
  13.   )
  14.   (if (equal lst2 '(202 194 181 227 176 236 206 210 176 239 196 227 205 208 208 214 213 212)  )
  15.        (setq lst2 '(202 174 181 227 176 235 206 210 176 239 196 227 205 209 208 216 213 214) )
  16.        );此句根据需要可取消
  17. (vl-list->string lst2)
  18. )
  1. 测试:
  2. (revstr  "赵兄托你帮我办点事")  ->...
  3. (revstr "(if (> (nth n lis) 128) ;任何字符ascii码超过128都是分两字节存放")-"放存节字两分是都821过超码iicsa符字何任; )821 )sil n htn( >( fi("
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-5-4 17:02 , Processed in 0.188970 second(s), 19 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表