Hi All,
Can MDL functions supports Unicode Characters?
If not what i will do to support Unicode Characters.
Thanks in Advance,
Jeyankondan.
Have a look at
int mdlCnv_convertMultibyteToUnicode ( char const* multibyteCharsP , int iMultibyteLength , MSWChar* unicodeCharsP , int iUnicodeLength );
and
int mdlCnv_convertUnicodeToMultibyte ( MSWChar const* unicodeCharsP , int iUnicodeLength , char* multibyteCharsP , int iMultibyteLength );
HTH
Mit freundlichen Grüßen / Best regards Volker Hüfner
| AB_DATE Engineering Software | ab-date.de |
Jeyankondan: Can MDL functions support Unicode Characters?
Can MDL functions support Unicode Characters?
In general, the answer is 'yes'. Many functions in V8 are Unicode-only. For example, a model or cell name & description are always Unicode:
mdlCell_create (..., MSWChar const* cellName , ...)
The MSWChar type, depending on your build environment, is either a typedef for UShort (a 16-bit value) or for wchar_t, the C++ standard Unicode character type. A Unicode character string variable in MDL is:
MSWChar unicode_string [MAX_MODEL_NAME_LENGTH];
Construct a literal Unicode string using the 'L' prefix:
MSWChar const* const_unicode_string = L"Jeyankondan";
There are complications: some APIs have not yet been converted and continue to use multibyte ANSI (8-bit char) strings. You can convert between multibyte and Unicode using mdlCnv_convertMultibyteToUnicode and mdlCnv_convertUnicodeToMultibyte.
The worst complication occurs when you want to construct a text element. The function to construct text is mdlText_createWide (... MSWideChar const* wString, ...), which, you observe, uses a unique data type MSWideChar not MSWChar. This, and its partner mdlText_extractWide, are the the only functions in the entire MDL API that uses that data type. It is not freely interchangable with either multibyte or Unicode, and requires conversion functions MSWideCharStringToMSWCharString and MSWCharStringToMSWideCharString.
Regards, Jon Summers LA Solutions
Hi Jon,
Thank you for your reply.
But now my problem is i'm retreiving data from database as Arabic Unicode characters, that i want to store in a sting list.
So i go for mdlStringList_.... functions.
and also mdlDialog_... functions (to display the data in Arabic characters),
EX: mdlDialog_optionButtonInsertItem,mdlDialog_listBoxInsertColumn...and so on.
The above mentioned functions are still supports only ASCII,
Will these functions support Unicode characters?, if not how to convert?
Thanks & Regards,
Jeyankondan: I'm retrieving data from a database as Unicode characters that I want to store in a string list.
I'm retrieving data from a database as Unicode characters that I want to store in a string list.
StringLists are a relic from the first version of MDL released in about 1993. They can accommodate only multibyte text (i.e. there is no Unicode version of StringList). StringLists are superseded in V8 by the ListModel.
A ListModel can accommodate various data types, including both multibyte and Unicode text and various numeric types.
If you want to display a list of text in, say, a ListBox, you can use a ListModel. For example, mdlDialog_listBoxSetListModelP.
Jon Summers:The worst complication occurs when you want to construct a text element. The function to construct text is mdlText_createWide (... MSWideChar const* wString, ...), which, you observe, uses a unique data type MSWideChar not MSWChar. This, and its partner mdlText_extractWide, are the the only functions in the entire MDL API that uses that data type. It is not freely interchangable with either multibyte or Unicode, and requires conversion functions MSWideCharStringToMSWCharString and MSWCharStringToMSWideCharString.
Ok, but am I correct that this will only work in XM or later?
Because it needs te following function definitions, and I cannot find, for instance, MSCORE_EXPORT in V8 2004 anywhere:
MSCORE_EXPORT int MSWideCharStringToMSWCharString (MSWCharP outString, UInt32 nOutChars, UInt16 const* inString) const; MSCORE_EXPORT int MSWCharStringToMSWideCharString (UInt16* outString, UInt32 nOutChars, MSWCharCP inString) const;
So can I decisively conclude from this that V8 2004 will not support unicode i.e. Arabic characters? Or are there other ways to convert MSWChar to MSWideChar (in order to use mdlText_createWide)?
Thanks, Jan
Jan: Am I correct that this will only work in XM or later? Can I decisively conclude from this that V8 2004 will not support Unicode?
Am I correct that this will only work in XM or later? Can I decisively conclude from this that V8 2004 will not support Unicode?
Neither. MicroStation V8.0 and later support Unicode and multibyte characters. Unfortunately, for reasons I don't understand, the text API is an ever-changing shop display. With V8i, for example, you can't use MDL functions at all: you have to use the C++ MicroStation API.
Jan: Because it needs the following function definitions, and I cannot find, for instance, MSCORE_EXPORT in V8 2004 anywhere:
Because it needs the following function definitions, and I cannot find, for instance, MSCORE_EXPORT in V8 2004 anywhere:
Because they don't exist in that version. You posted in the XM Forum, so I've answered an XM question. For the reasons stated above, this is one occasion when you should definitely post your question to the correct Forum, because the answers are version-specific.
Jeff Marker is Bentley's text API guru, I believe. He has posted some stuff about text and MDL on his wiki and elsewhere.
OK. We must need the below mentioned functions and structures that should support MSWChar data type in Microstation V8 and Microstation V8 XM, but these functions are only support char data type.
Functions:
mdlDB_activeDatabase mdlDB_openCursor mdlDB_fetchRow mdlDB_processSQL
mdlDialog_optionButtonInsertItem mdlDialog_itemGetValue mdlWindow_textDraw mdlWindow_textDrawCD mdlWindow_titleSet
Structures:
MS_sqlda
DialogBoxRsc DItem_ListBoxRsc DItem_PushButtonRsc DItem_OptionButtonRsc DItem_TextRsc DItem_ToggleButtonRsc DItem_ComboBoxRsc
Is there any alternate solution?
Displaying unicode characters (i.e. Arabic) in dialog boxes is one thing, but eventuelly they need to be added to the DGN as Text items, and I can't get that to work either. It is possible to add special characters to the DGN by copying characters from Microsoft Word to the Text Word Processor. But even then, if I extract these characters with mdlText_extractWide and instantly create a new Text item from that, using mdlText_createWide, it doesn't work. It seems that it's unable to handle unicode above 256.
This is what Jeff Marker told me in a PM:
Generally speaking, unless there is a Unicode variant of a function (e.g. one that takes MSWChar), you are generaly limited to representing text in the ACP only. These MBS (multi-byte string) functions (e.g. those that take char*) can only represent text in a single locale, and that locale is generally assumed to be ACP. If you are in an Arabic locale, then Unicode to MBS is possible and should display correctly (* I can't claim our RTL handling is particularly well tested though; in fact we recently discovered up to V8i we actually write the string backwards into the element to get RTL for RSC and SHX fonts, which is most horrific to put it mildly).
Currently, MicroStation text elements should store their string in the locale of their font. Until V8i, there was no way to tell MicroStation what locale a given font was, so ACP was assumed for any locale font (e.g. all RSC fonts and some SHX fonts); therefore, depending what font you are using will determine what you can pass to the text functions. The next major release of MicroStation will have a fully Unicode C++ text API that should resolve all of these locale issues; a file-format change to always store text as Unicode would also help us a lot, but I have no idea when I'll be able to do that as file format changes are a very touchy issue.
So in V8 and XM it all seems to depends on your active code page. If anybody has a solution to this, if you know how to get this to work in V8 or XM, please let me know.
Kind regards, Jan
Jan: So in V8 and XM it all seems to depends on your active code page. If anybody has a solution to this, if you know how to get this to work in V8 or XM, please let me know.
Try something along these lines in your main():
//C and C++ programs start up in the "C" locale. To make them use the //current system locale for everything, say: ::setlocale (LC_ALL,"");