Jump to content
grandhougday

Ascii and (vl-string-elt) give wrong answers!!

Recommended Posts

marko_ribar

Look I am not saying that Lee's function isn't good... It's working - I've checked it with list '(92 85 43 48 48 68 69) and (_ascii lst) gave result 222... I am just saying that on both my comps. (netbook with A2008 ) and (PC with A2012), when typed at command line : (vl-string->list "Þ") the result was (222), so I am guessing something's wrong with your CAD, or I am guessing wrong, I should get (92 85 43 48 48 68 69) as result???

 

M.R.:?

Share this post


Link to post
Share on other sites
Ahankhah
Are you sure you are testing it correctly?

 

For me:

_$ (ascii "Þ")
222

 

This is the result:

Command: (vl-string->list "Þ")
(92 85 43 48 48 68 69)

 

This is some sort of wrong result - on my comp it's correct :

 

Command: (vl-string->list "Þ")
(222)

M.R.:)

 

what is your Dwgcodepage?

 

(getvar 'Dwgcodepage)

Share this post


Link to post
Share on other sites
Lee Mac
Lee,

let me edit your excellent code so the internal "ascii" function can be replaced with the new one:

 

Thank you Ahankhah :)

 

I might be inclined to code it in this way to save some unnecessary calls:

 

(defun _ascii ( ch / ls )
   (if (setq ls (cdddr (vl-string->list ch)))
       (_HexList->Decimal (reverse ls))
       (ascii ch)
   )
)

(defun _HexList->Decimal ( lst )
   (if lst
       (+  (* 16 (_HexList->Decimal (cdr lst)))
           (if (< (car lst) 65)
               (- (car lst) 48)
               (- (car lst) 55)
           )
       )
       0
   )
)

Though, both are equally valid :)

Share this post


Link to post
Share on other sites
marko_ribar

Command: (getvar 'Dwgcodepage)
"ANSI_1252"

 

M.R.

Share this post


Link to post
Share on other sites
Ahankhah
Command: (getvar 'Dwgcodepage)
"ANSI_1252"

 

M.R.

 

Your codepage is English, so the reply is correct.

Mine is Arabic ("ANSI_1256"), so I guess the reason for different behavior of AutoCAD is not due to a bug.

Share this post


Link to post
Share on other sites
Lee Mac
Your codepage is English, so the reply is correct.

Mine is Arabis ("ANSI_1256"), so I guess the reason for different behavior of AutoCAD is not due to a bug.

 

Exactly, Windows-1252 includes the Extended ASCII set (128-255), Windows-1256 (and most other code pages) does not - hence such characters are rendered as Unicode code-points)

Share this post


Link to post
Share on other sites
Ahankhah

Thank you Lee for your helps. :)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...