Closed igortheodoro closed 1 year ago
Hello,
Thanks for your contribution! Seems fixing it in such a way breaks the example, the layer cannot be longer hidden by unchecking its checkbox. Probably it happens because the layer original name is still used as a key in the layers collection, as well as in references from all document entities. Some common approach should be introduced, either using this conversion only for display purposes, or convert it everywhere. Also some special sequences like %%d
may be parsed as well (BTW there already exist corresponding method _ParseSpecialChars()
which may be moved somewhere to reuse it) . Also some other entities may be affected, not only layers (block names, dimstyles, etc.), so this should be solved in a complex manner. I have created corresponding issue.
I added a new property on the layer object that contains the normalized layer name. In this way, we can use the "normalizedName" property which contains the layer name with the converted unicode characters.
And the code to display the list of layers would look like this: `
`
Layers that had special characters in the name were converted to Unicode characters (\U+XXXX).
So to solve this I used the String.replace() function to replace the characters in Unicode with a group of characters. Then the String.fromCharCode() function is used to convert the string of characters to its equivalent in ASCII characters. Finally, the conversion result is returned to the String.replace() function.
In this file File.zip have the DXF to test.