acedGetString seems to return ANSI string from file

acedGetString seems to return ANSI string from file

Anonymous
Not applicable
1,641 Views
4 Replies
Message 1 of 5

acedGetString seems to return ANSI string from file

Anonymous
Not applicable

Hi, I have such scenario:

 

From my arx application:

- load LISP file using (LOAD "filename")

- LISP calls then some commands

- A command asks user for string, but this string is written in LISP file, so acedGetString returns immidiately with passed value... almost.

 

The problem is that it seems acedGetString in such case returns string converted to ANSI. The file is originally saved in UNICODE. Is there any way to get the string as unicode?

 

My code is really simple:

AcString str;
int status = acedGetString(1, L"Give me string", str);
0 Likes
Accepted solutions (2)
1,642 Views
4 Replies
Replies (4)
Message 2 of 5

autodaug
Autodesk
Autodesk
Accepted solution

Hi,so you're saying you have a custom command defined in a C++ ARX app which is calling acedGetString(), and the command is being called from a lisp script, which also supplies the input string to the command.  And your Lisp script is a utf8 text file, with some non-Ascii characters in it, such as Euro or Copyright or whatever, but the AcString object contains garbage instead of those characters?

 

Unfortunately, Lisp currently interprets input files as Ansi, even if they are stored in utf8 format (even if they have the utf8 Byte-Order-Mark). This is a known limitation that is being looked into.  For now, I think it's best to store your Lisp script as an Ansi text file instead of as Utf-8.  That should cause your non-Ascii characters (i.e. those with codes > 128) to be read in properly.  Can you try that?

 

The main problem with Ansi files of course is that they are tied to the original code page, so if you take the file to another system using a different code page (e.g. the file is created on 1252 Western code page and you take it to a Japanese 932 code page system), some non-Ascii chars may not be read or displayed properly. If you need to work around this, there are escape sequences that are understood by Lisp which you can use, but it's a little tedious.

 

 

 

 

0 Likes
Message 3 of 5

Alexander.Rivilis
Mentor
Mentor

@Anonymous wrote:

Hi, I have such scenario:

 

From my arx application:

- load LISP file using (LOAD "filename")

- LISP calls then some commands

- A command asks user for string, but this string is written in LISP file, so acedGetString returns immidiately with passed value... almost.

 

The problem is that it seems acedGetString in such case returns string converted to ANSI. The file is originally saved in UNICODE. Is there any way to get the string as unicode?

 

My code is really simple:

AcString str;
int status = acedGetString(1, L"Give me string", str);

acedGetString return string entered by user, but not string from file. And string is UNICODE since AutoCAD 2007.

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

0 Likes
Message 4 of 5

moogalm
Autodesk Support
Autodesk Support

Hi,

 

One workaround is to mix arx lisp callable command with in script file, 

acedGetString

should work with script inputs.

 

0 Likes
Message 5 of 5

autodaug
Autodesk
Autodesk
Accepted solution

Good point, AutoCAD does read utf-8 script (.scr) files properly. It's just the Lisp (.lsp) files that do not currently have utf-8 support.  So you can move the "non-ascii" parts of the Lisp file into (utf-8 format) script files and call those scripts from Lisp.

 

Btw, this issue isn't specific to custom commands or ARX apps. You would have the same problem using native commands (e.g. layer, text, etc) in a Lisp file. If the Lisp file contains non-ascii chars, they are interpreted as Ansi, even if the Lisp file has utf-8 format.

 

0 Likes