高级会员
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
|
【转帖】unicodeansi String
unicode/ansi string
unicode/ansi string
we have an app that uses the legacy opendwg toolkit library. because the opendwg toolkit library doesn't support unicode (all the strings such as layer name, block name, text and mtext entity contents are all returned as char* buffer, potentially with the /u+ encoding for non-ansi characters), we have code that take the char* buffer and convert the string to unicode for display. now we are considering switching to dwgdirect library. dwgdirect supports unicode - all the strings are returned as odstring with unicode wchar buffer. since it's costly to rewrite our code that depends on the fact that all strings passed over from the opendwg library are char* buffers, i wonder if there is a way to use the dwgdirect library but retriving all the strings as ansi string. for example, when the library reads in a text entity with japanese characters, the unicodebuffer field of the oddbtext object will contain the unicode string, will the ansistring field contain the corresponding encoded (with /u+) ansi string? what other options do i have? appreciate your help.
i've looked into this a little more - so let me try to clarify my question:
here is my observation: when i use dwgdirect to read in strings (such as text entity content) from a dwg/dxf file, if the version is below r21, the odstring object will have the ansistring buffer filled; if the version is above r21, it will have the unicodebuffer filled. and it seems i can easily convert between the unicode string and the ansi string.
so, am i correct to assume that i can freely retrieve either the unicode string or the ansi string as i see fit? in my case, my existing code wants the string to be ansi string (with ansi characters, mbcs characters, or encoded "\u+xxxx" and "\m+nxxxx" strings). should i simply cast the odstring object to odansistring to then return the buffer?
thanks!
quote:
originally posted by jason1
so, am i correct to assume that i can fly rereetrieve either the unicode string or the ansi string as i see fit? in my case, my existing code wants the string to be ansi string (with ansi characters, mbcs characters, or encoded "\u+xxxx" and "\m+nxxxx" strings). should i simply cast the odstring object to odansistring to then return the buffer?
thanks!
you may get unicode string or the ansi string in any place. for example:
oddbtextptr ptext;
odstring str = ptext->textstring(); // for odstring "const odchar* c_str() const"
odansistring ansistr(str); // for odansistring "const char* c_str() const"
best regards,
sergey z.
|