几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量

几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 (http://www.dimcax.com/hust/index.php)
-   DirectDWG (http://www.dimcax.com/hust/forumdisplay.php?f=89)
-   -   【转帖】mtext, setcontents and shift jis encoding (http://www.dimcax.com/hust/showthread.php?t=17277)

yang686526 2009-05-06 06:13 PM

【转帖】mtext, setcontents and shift jis encoding
 
mtext, setcontents and shift jis encoding
mtext, setcontents and shift jis encoding
hello
i am using opendwg library upgraded to the version 2.2.0. i have a little problem (maybe not little). this is situation:
1)
oddbmtextptr pmtextent = oddbmtext::createobject();
char *textstorage; /* this variable is a pointer to the string which has unicode notation like u+xxxx */
....
pmtextent->setcontents(textstorage);
setcontents metod work correctly with this string. in mtext entity i have a same string as i put to the textstorage pointer.
2)
oddbmtextptr pmtextent = oddbmtext::createobject();
char *textstorage; /* this variable is a pointer to the string which is now shift jis encoded */
....
pmtextent->setcontents(textstorage);
now setcontents function does not work correctly with this string. in dxf file i have something like mix u+xxxx notation and shift jis chars encoded.
i have only one wish, that i have in dxf file same string as i put it in textstorage variable. in this case that is string encoded as a shift jis.
is it possible to do now with opendwg version 2.2.0.
ervin.
hello ervin,
possible there is problem with conversion your string to unicode (and back while saving dxf version befor r21). try to use odansistring class. you can initialize it by your string and use setcodepage(cp_ansi_932).
code:
odansistring str(textstorage);
str.setcodepage(cp_ansi_932).
odstring content(str);
pmtextent->setcontents(str);
best regards,
sergey z.


所有的时间均为北京时间。 现在的时间是 04:46 PM.