编程语言
首页 > 编程语言> > Java操作DXF中增加中文文本的问题

Java操作DXF中增加中文文本的问题

作者:互联网

采用java 编写dxf文本,在添加中文文本的时候,有点问题,采用cad打开时会显示dxf文件没有完成。

其原因在dxf文件要采用Unicode编码,所以要将需要在dxf中显示的中文修改为Unicode的十六进制编码,就是而且必须应该是\u+0XXX的格式,且必须是4位,对于字母,数字等必须要采用0进行补位,否则cad中不能正常显示。

另外,cad要显示中文,还需要将header中的$DWGCODEPAGE 设置为ANSI_936。

参考如下:DXF File Encoding — ezdxf 0.15.1 documentation

Drawing files of DXF R2004 (AC1018) and prior are saved as ASCII files with the encoding set by the header variable $DWGCODEPAGE, which is ANSI_1252 by default if $DWGCODEPAGE is not set.

Characters used in the drawing which do not exist in the chosen ASCII encoding are encoded as unicode characters with the schema \U+nnnn. see Unicode table  

 

 

 

 

 

 

 

 

 

 

标签:dxf,中文,Java,Unicode,DWGCODEPAGE,DXF,文本,cad
来源: https://blog.csdn.net/tianyatest/article/details/120334060