mozman / dxfgrabber

Outdated DXF reader, please switch to ezdxf (UNMAINTAINED)
Other
66 stars 15 forks source link

Silent failure with latin unicode #13

Closed AedonGrunGott closed 6 years ago

AedonGrunGott commented 6 years ago

Howdy. I've not delved into this too deeply, but I think dxfgrabber is having a hard time with characters such as Ë or Ò from the Latin-1 Unicode supplement.

When block names have such characters in them, they are passed over without any notification. Manually changing offending characters (from Ë to E, for example) solves the problem.

mozman commented 6 years ago

Can you provide a small example file?

AedonGrunGott commented 6 years ago

Apologies for the delay, but it gave me time to dig into it and there is something else going on I'm not grasping, as realized when making super simple test files.

I'm attaching four files. The "simple" ones are a few rectangles where "_a" has accented characters and "_b" does not. I treated the "larger" files the same way. DXFGrabber works fine on both simple files, and the unaccented larger file. The accented larger file does not work right.

They are all ASTM dxfs, which are ideally standardized, but sadly in practice everyone writes them a little differently.

4-dxfs.zip

mozman commented 6 years ago

Hi!

The DXF files have a HEADER section but no header vars declared, so dxfgrabber defaults to:

On Windows and Python 3.6 I got this block names as result:

As I saw, you are working on a Mac, maybe this is a Mac specific problem, which I can't solve.

If you are using Python 2.7 -> more encoding problems ;).

You can try the low level read function: _read_encoded_file(filename, options=None, encoding='utf-8', errors='strict')

mozman commented 6 years ago

This are the block names fetched by dxfgrabber for test-lager_a: 459720-11-30--Ë-Ò-18_16 459720-11-30--Ë-Ò-18_18 459720-11-30--Ë-Ò-18_20 459720-11-30--Ë-Ò-18_22 459720-11-30--Ë-Ò-18_24 459720-11-30--Ë-Ò-18_26 459720-11-30-¹ÒÃÆ-18_16 459720-11-30-¹ÒÃÆ-18_18 459720-11-30-¹ÒÃÆ-18_20 459720-11-30-¹ÒÃÆ-18_22 459720-11-30-¹ÒÃÆ-18_24 459720-11-30-¹ÒÃÆ-18_26 459720-11-30-ÁÌ-18_16 459720-11-30-ÁÌ-18_18 459720-11-30-ÁÌ-18_20 459720-11-30-ÁÌ-18_22 459720-11-30-ÁÌ-18_24 459720-11-30-ÁÌ-18_26 459720-11-30-Ç-ÏÂ-ÚÏÂ-18_16 459720-11-30-Ç-ÏÂ-ÚÏÂ-18_18 459720-11-30-Ç-ÏÂ-ÚÏÂ-18_20 459720-11-30-Ç-ÏÂ-ÚÏÂ-18_22 459720-11-30-Ç-ÏÂ-ÚÏÂ-18_24 459720-11-30-Ç-ÏÂ-ÚÏÂ-18_26 459720-11-30-ºÓÏÂ-ÚÏÂ-18_16 459720-11-30-ºÓÏÂ-ÚÏÂ-18_18 459720-11-30-ºÓÏÂ-ÚÏÂ-18_20 459720-11-30-ºÓÏÂ-ÚÏÂ-18_22 459720-11-30-ºÓÏÂ-ÚÏÂ-18_24 459720-11-30-ºÓÏÂ-ÚÏÂ-18_26 459720-11-30-ºÓÏÂ-ÚÉÏ-18_16 459720-11-30-ºÓÏÂ-ÚÉÏ-18_18 459720-11-30-ºÓÏÂ-ÚÉÏ-18_20 459720-11-30-ºÓÏÂ-ÚÉÏ-18_22 459720-11-30-ºÓÏÂ-ÚÉÏ-18_24 459720-11-30-ºÓÏÂ-ÚÉÏ-18_26 459720-11-30-Ç-ÏÂ-ÚÉÏ-18_16 459720-11-30-Ç-ÏÂ-ÚÉÏ-18_18 459720-11-30-Ç-ÏÂ-ÚÉÏ-18_20 459720-11-30-Ç-ÏÂ-ÚÉÏ-18_22 459720-11-30-Ç-ÏÂ-ÚÉÏ-18_24 459720-11-30-Ç-ÏÂ-ÚÉÏ-18_26 459720-11-30-ºÓÆ--18_16 459720-11-30-ºÓÆ--18_18 459720-11-30-ºÓÆ--18_20 459720-11-30-ºÓÆ--18_22 459720-11-30-ºÓÆ--18_24 459720-11-30-ºÓÆ--18_26 459720-11-30-Ç-Æ--18_16 459720-11-30-Ç-Æ--18_18 459720-11-30-Ç-Æ--18_20 459720-11-30-Ç-Æ--18_22 459720-11-30-Ç-Æ--18_24 459720-11-30-Ç-Æ--18_26 459720-11-30-ÐÄÆ--18_16 459720-11-30-ÐÄÆ--18_18 459720-11-30-ÐÄÆ--18_20 459720-11-30-ÐÄÆ--18_22 459720-11-30-ÐÄÆ--18_24 459720-11-30-ÐÄÆ--18_26

AedonGrunGott commented 6 years ago

Well I'll be darned if I can figure out what's going on. The effort on your end is very much appreciated... but I can't nail down the bug via a generated/false dxf as of yet.

For now, I am comfortable calling this a limited problem on my system/environment and closing the issue for now. The process of breaking things will continue for me, and if something turns up I'll pop back.

mozman commented 6 years ago

My ezdxf package also reads (and writes) DXF files, but I assume it will not solve your problem. dxfgrabber is older and just in maintenance mode, ezdxf is still in active development, but has a different interface.

ezdxf is on PyPI:

pip install ezdxf

Documentation at Read the Docs. And it has (now) a own website: ezdxf.mozman.at