Author Topic: Unicode in string  (Read 1384 times)

0 Members and 1 Guest are viewing this topic.

dgpuertas

  • Newt
  • Posts: 80
Unicode in string
« on: May 18, 2017, 06:20:14 AM »

Its possible to put UNICODE characters in a string variable in Autolisp?

I want to use the Word equation editor to write values ​​from autolisp.
This editor uses the math autocorrector through the property "OMathAutoCorrect" and its "Entries"
For example \beta will be β

Code: [Select]
(setq *msw* (vlax-get-or-create-object (vl-registry-read "HKEY_CLASSES_ROOT\\Word.Application\\CurVer")))
(vlax-for ac (vlax-get-property (vlax-get-property *msw* 'OMathAutoCorrect) 'Entries)
(princ (vlax-get-property ac 'Name))(princ " = ")(princ (vlax-get-property ac 'Value))(princ " \n "))

But most of the characters appear as "?" Because (I think) are unicode

 \bet = ?
 \beta = ß
 \beth = ?
 \Alpha = ?
 \Bar = ?
 \Beta = ?
 \Chi = ?
 \Dd = ?


Is it possible to get that value in a variable to write it in ms word?

Thanks and sorry for my "googletranslator" english


Andrea

  • Water Moccasin
  • Posts: 2372
Re: Unicode in string
« Reply #1 on: May 29, 2017, 01:18:12 PM »
maybe something like this...?

Code: [Select]
(set (read (strcat "Variable_" (chr 914))) "test")

;test
(eval (read (strcat "Variable_" (chr 914))))
Keep smile...

dgpuertas

  • Newt
  • Posts: 80
Re: Unicode in string
« Reply #2 on: May 30, 2017, 06:22:12 AM »
Thanks Andrea

Finally i use the character as a number and use word method to write the equation.

Code: [Select]

(defun word_inserta_ecuacion_lista (lista)
   (mswm-Collapse *range* mswc-wdCollapseend)
   (setq sel (vlax-get-property (vlax-get-property *range* "Application") "Selection"))
 
   (mswm-select *range*)
 
  (foreach a (split-list 2 lista)
    (mswm-Collapse sel mswc-wdCollapseend)
    (mswm-TypeText sel (car a))
    (mswm-Collapse sel mswc-wdCollapseend)
    (if (cadr a) (mswm-InsertSymbol sel (cadr a) "Cambria Math" :vlax-true)))
     
  (mswp-put-end *range* (mswp-Get-Start sel))
  (setq omaths (mswm-Add (mswp-get-OMaths *range*) *range*))
  (mswm-BuildUp (mswm-item (mswp-get-OMaths omaths) 1))
)

And use the equation as a list with text and integer (special character)
Code: [Select]

(word_inserta_ecuacion_lista (list "P_MAX=" 8730 "(3) U I cos(" 966 ")="8730 "(3) 20 kV 50 0A 0,95=16,4 MW"))


8730 is the code of sqrt
966 ins the unicode value of fhi greek

And in word appears the equation good.
« Last Edit: May 30, 2017, 06:32:14 AM by dgpuertas »