LibreDWG / libredwg

Official mirror of libredwg. With CI hooks and nightly releases. PR's ok
https://savannah.gnu.org/projects/libredwg/
GNU General Public License v3.0
965 stars 231 forks source link

Simplified Chinese decoding #945

Closed xiuweihan closed 7 months ago

xiuweihan commented 8 months ago

Use dwglayers.exe: libredwg-0.13.3-win64.zip to output the layer names of the dwg file. Some layers contain Chinese characters and garbled characters are output.

file: read_layer_name.zip

result: 0 鍖哄煙-green area PV ARRAY LIMIT site 鍖哄煙 E-SUBSTATION E-INVERTER_STATION 鍖哄煙-閬撹矾 *ADSK_SYSTEM_LIGHTS DGX GstarFastview4.2-ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-note-layer-HCNoteLayer ZAW

rurban commented 8 months ago

The names do look good to me. Are they wrong?

rurban commented 8 months ago

I'm having trouble with my hard disc, with constant corruptions. Will need some time

rurban commented 7 months ago

oda converts them to these layers, the logs do contain the same encodings.

0 区域-green area PV ARRAY LIMIT site 区域 E-SUBSTATION E-INVERTER_STATION 区域-道路 *ADSK_SYSTEM_LIGHTS DGX GstarFastview4.2-ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-note-layer-HCNoteLayer ZAW

They still do look very chinese to me. which makes sense, since the codepage is ANSI_936 Simplified Chinese.

And dwglayers does look right:

programs/dwglayers ../ti/gh945/read_layer_name.dwg 0 区域-green area PV ARRAY LIMIT site 区域 E-SUBSTATION E-INVERTER_STATION 区域-道路 *ADSK_SYSTEM_LIGHTS DGX GstarFastview4.2-ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-note-layer-HCNoteLayer ZAW

So it looks like your console codepage does not display UTF-8 correctly.

zefreestijl commented 7 months ago

Hi, I've encountered the same problem recently, as rurban says, the program or the library itself is correct, the problem is from codepage of your default console,

add line of : system("chcp 65001") at the begins of mian() works for me.

rurban commented 7 months ago

The library was not quite correct, just found a major decoding problem: #959 But this should not affect you in this case.