'Import nodeset in node-opcua server opens file ascii encoded

I create the node-opcua addressspace by usage of nodeset.xml files. I fill the server_options.nodeset_filename array with filenames to load.
This works fine.
Now I wanted to load the nodeset "Opc.Ua.Ijt.Tightening.NodeSet2.xml" from companion specification for tightening (https://github.com/OPCFoundation/UA-Nodeset/blob/v1.04/IJT/Tightening/Opc.Ua.Ijt.Tightening.NodeSet2.xml) and recognized that some descriptions are cut if connecting to the server and reading with an opcua client.
For example UAVariable NodeId="ns=1;i=6094" contains field 'Error' with description '0 – OK ...'.
The '-' in '0 - OK' is utf-8 encoded character in the nodeset xml.
After some investigation I found fs.readFile(xmlFile, "ascii", (err, xmlData: string) in export function readNodeSet2XmlFile https://github.com/node-opcua/node-opcua/blob/master/packages/node-opcua-address-space/source_nodejs/generate_address_space.ts#:~:text=fs.readFile(xmlFile%2C%20%22ascii%22%2C%20(err%2C%20xmlData%3A%20string)

The OPC UA specification tells 'All String values are encoded as a sequence of UTF-8 characters'.

Questions:

  • Does node-opcua really read nodeset xml 'ascii' encoded or is it my wrong interpretation?
  • Is there a way to force node-opcua to use 'utf-8' encoding when reading nodesets?


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source