nls error
nls error
we use dwgdirect version 2.2.0.0 and facing an issue in all .dwg file that we generate from our application.
when the generated .dwg files are opened in autocad 200/2004/2006/2008 etc., autocad gives the below warning:
"nls files required to convert text entities and symbol table in your dwg file from code page ascii to ansi_1252 cannot be found or not installed, etc...".
if the user chooses continue, he/she can open the file.
this happens for all the dwg files (and not .dxf)that our application generates.
what can be the possible reason for this warning message from autocad?
has anyone else faced such issue ?
tia
last edited by
harshv@adobe.com; 6th august 2008 at 05:01 amfff">.
hello harsha,
check codepage of your database and check your implementation oddbsystemservices :: systemcodepage().
could you attach your sample file?
note version 2.2.0.0 was released two years ago and possible this problem is resolved now. try to use latest version dwgdirect 2.6.1.
best regards,
sergey z.
hi sergey,
i will try with 2.6.1 and will update the thread.
thanks,
harsha
the message about missing nls files may appear in autocad even if the file was created by autocad on another computer with different code page.
for example you create (in autocad) a file on japanese computer. it has code page ansi_932.
you open it on american computer without installed windows support for 932 code page.
autocad gives warning that windows support for characters conversion (nls files) are not installed.
in your case the message "... required to convert ...from code page ascii to ansi_1252 ..."
means that your implementation oddbsystemservices :: systemcodepage() returns ascii code page. this is not a standard windows code page and where is no nls files for it.
actually ascii means that only standard characters with codes < 128 are used and no nls files are required because the character codes are the same in all code pages. this is autocad's bug to give such message for ascii code page.
i don't think upgrading dd version may help. you need to fix your implementation of oddbsystemservices :: systemcodepage().
hi sslezkin.
you are right, moving to newer version of library is not fixing the problem. regarding the code page i checked that i have a class defined in exsystemservices.cpp as:
class exsystemservices : public oddbsystemservices
it has a variable m_codepageid which retains the code page id. m_codepageid is initialized in the constructor of exsystemservices. and it decides that based on the retun value of win api getacp() call. currently m_codepageid is set to cp_ansi_1252.
exsystemservices::exsystemservices()
: m_codepageid(cp_undefined)
{
#ifdef _win32
switch(::getacp())
{
case 874:
m_codepageid = cp_ansi_874;
break;
case 932:
m_codepageid = cp_ansi_932;
break;
case 936:
m_codepageid = cp_ansi_936;
break;
case 949:
m_codepageid = cp_ansi_949;
break;
case 950:
m_codepageid = cp_ansi_950;
break;
case 1200:
m_codepageid = cp_ansi_1200;
break;
case 1250:
m_codepageid = cp_ansi_1250;
break;
case 1251:
m_codepageid = cp_ansi_1251;
break;
case 1252:
m_codepageid = cp_ansi_1252;
break;
case 1253:
m_codepageid = cp_ansi_1253;
break;
case 1254:
m_codepageid = cp_ansi_1254;
break;
case 1255:
m_codepageid = cp_ansi_1255;
break;
case 1256:
m_codepageid = cp_ansi_1256;
break;
case 1257:
m_codepageid = cp_ansi_1257;
break;
}
#endif
}
systemcodepage() is defined in exsystemservices and returns m_codepageid.
odcodepageid exsystemservices::systemcodepage() const
{
return m_codepageid;
}
what needs to be rectified in the above code?
this code is ok. but based on the text of message autocad gives (from your first post) i see that file is created in "ascii" code page.
if you work on windows and you have not overloaded systemcodepage() than the question is: are you creating the new drawing from scratch or you load existing file? what code page is in dxf files? - at the beginning of the file:
9
$dwgcodepage
3
ansi_1252 // or "ascii" ?
in dxf files i see
9
$dwgcodepage
3
ansi_1252
i have no idea what is happening. dxf files are saved ok with ansi_1252 code page.
autocad message you wrote about in your first post says that dwg file's code page is "ascii". are you sure that the files (dwg & dxf) were saved on the same computer by the same program without changing regional settings and from the same source database?
are you converting existing files or creating new files from scratch?
i am creating files from scratch.
if you create files from scratch than your computer's system code page is used for the newly created files.
could you run odwriteex sample on your computer to create dxf and dwg files of the same version you create by your application and see if they are ok or show the same problem (message about missing nls files for "ascii" code page)?
hi sergey,
i tried to use the sample code odwriteex, both for mac (tiger) and win (xp), with dwddirect 2.6.3 and created files for autocad 2007 on both platforms. i can see the files created on win with 2.6.3 is no more giving problem but the ones created on mac are still giving the missing nls file error. with earlier version of the library(2.6.1) we had problem on both mac & win. please find the files created(using odwriteex) on mac & win, attached. i would like to mention again that the problem is with dwg files only when we create them using dwgdirect libraries and open in autocad.
thanks,
harsha
attached files (90.4 kb, 1 views)
(91.0 kb, 0 views)
on non-windows platform you need to take care about system code page yourself. see the source code above in this thread.
you can overload oddbsystemservices :: systemcodepage().
or call exsystemservices::setsystemcodepage()
sergey slezkin
hi sergey,
i got it that it has to be taken care on mac. above code which you referred is posted by me only. can you tell me that as we have :getacp() on win, what is the corresponding api on mac to get the code page?
-harsha
hi sergey,
i am back to the thread with some observations done while making some changes in my code. observations are as follows:
i). when files are saved with codepage info as ascii. dxf files don't give any error message but dwg files do give "nls files required..." error message as stated in the first message of the thread.
ii). when files are saved with codepage info as ansi_932 then there is not error message.
i have three questions around above mentioned behavior.
1. what is codepage information?
2. why do we need to give code page info while writing files? is there a way skip mentioning the codepage info to avoid the error message. and if there is a way to do that, then is there a potential problem if we don't mention codepage information.
3. why things work fine when code page is hardcoded as ansi_932. is this a correct thing to hardcode the codepage information?
thanks,
harsha
code page defines charset of texts stored in file. only latest autocad versions stores string data (texts) in unicode. olders versions store strings in mbcs. to display national characters (with code > 127) correctly on computer with another locale (for example to view on russian computer a drawing created on japanese computer) it's important to know the code page of the drawing.
it's impossible to skip code page information because it's part of file format (some value must present).
dwgdirect starting with version 2.0 stores texts at run time in unicode. if you pass to an api function non-unicode string it's converted from mbcs to unicode assuming that the non-unicode string has encoding defined by system code page.
for example oddbsymboltable::setname(const odstring& name);
odstring has constructor accepting odchar* (pointer to wide character) - no conversion is performed.
and a contructor accepting const char*. in this case conversion is perfomed from mbcs to unicode.
among autocad's code pages where is only one macintosh - cp_macintosh - mac-roman.
i'm not mac specialist and i may be wrong but it seems that the only safe way to produce valid files containing national characters on macintosh is to use only unicode in your program while passing strings to dd api functions:
player->setname("mylayer"); // this is safe only for english characters
player->setname(l"mylayer"); // unicode string is passed to api function
if you pass only unicode strings to dd api than it's not important if drawing code page is absolutely correct or not and it can be hardcoded as "mac-roman" for example.
because latest file format versions store strings in dwg as utf16 and in dxf as utf8.
while saving to minor versions characters which can't be converted to drawing's code page will be represented as mif or cif sequences (\m+nxxxx or \u+xxxx)
sergey slezkin