Encoding issue in AS 4.12

Hello everyone,

i noticed that AS saves tasks written in LAD as an XML file which can be edited by any text editor. That sparked the idea that i might be able to generate some repetitive networks by using python to generate the XML from a list of tag names and comments which i have availabe inside of an excel file anyway (customer requires the program to be written in LAD). My python script worked alright, and the resulting XML was parsed correctly by AS.

Now my issue arises from umlauts in the comments (Ă€, ö, ĂŒ). Those are not represented in the ASCII character set. No big issue as i just encode my XML as UTF-8.
Opening any LAD task with Notepad++ also says that its encoded as UTF-8, yet still opening the file in the LAD editor doesnt render these Umlauts correctly.

Here is what i mean:

Example network, viewed by opening the LAD task in Notepad++:

	<network label="" comment="ABL Ventilatoren 13-18 Freigabe
Weitergabe der Einzelstörungen  an Sammelstörung der Anlage" row="2" column="0" commented="0">
		<row>
			<contact type="open" name="W_71520DAB_11L014ABFU6YSAR.AlMk"/>
			<line/>
			<line/>
			<coil type="set" name="L014_SST"/>
		</row>
		<row>
			<contact type="open" name="W_71520DAB_11L014VEM06YSAG.AlMk" or="true"/>
			<empty/>
			<empty/>
			<empty/>
		</row>
	</network>

Network comment, viewed inside the LAD editor:

ABL Ventilatoren 13-18 Freigabe
Weitergabe der Einzelstörungen  an Sammelstörung der Anlage

How can i fix this? When i enter Umlauts manually in the Network comment inside the LAD editor, they get rendered correctly.

As always, thanks in advance!

Hi Rudi,

I tried your code copying to the .ld file opened in Notepad++ and at the beginning I had the same problem as you. However if you change the encoding to ANSI (by default is in UTF-8). The problem is solved.


image

I hope this helps you :slight_smile:

2 Likes

Ah nice find! So that means i should save my file directly with ANSI encoding instead of UTF-8?

Thats exactly how i do it right now, which produced this issue.

Python:
with open('output.txt', 'w', encoding='utf-8') as file:

So my python file correctly outputs the XML with umlauts. Just opening this XML in the graphical LAD editor in AS doesn’t render the umlauts correctly.

ok other way around, that is also new for me :slight_smile: learning everyday :slight_smile:

2 Likes