<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Hello,</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
I'm searching for a solution for an encoding error (a possible constraint violation) that occures when the following struct is in the data to encode.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
I'm trying to pass an ecoded string to company name that turns to garbage. This only happens in the first encoding iteration the next ones are fine (the string is always the same).<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<pre style="background-color:#ffffff;color:#080808;font-family:'JetBrains Mono',monospace;font-size:9.8pt"><span style="color:#0033b3">typedef unsigned char OSUTF8CHAR;</span></pre>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<pre style="background-color:#ffffff;color:#080808;font-family:'JetBrains Mono',monospace;font-size:9.8pt"><span style="color:#0033b3">struct </span><span style="color:#008080">ASN1T_DangerousGoodsExtended </span>{<br><br>%TypeHeaderCode<br><span style="color:#9e880d">#include </span><span style="color:#067d17"><ITS-Container.h><br></span>%End   <pre style="background-color:#ffffff;color:#080808;font-family:'JetBrains Mono',monospace;font-size:9.8pt"><span style="color:#8c8c8c;font-style:italic">   // ...</span><br></pre>   <span style="color:#0033b3">const OSUTF8CHAR</span>* <span style="color:#660e7a">companyName</span>; // <- causes the encoding error<br><pre style="background-color:#ffffff;color:#080808;font-family:'JetBrains Mono',monospace;font-size:9.8pt"><pre style="background-color:#ffffff"><span style="color:#8c8c8c;font-style:italic">   // ...</span></pre></pre><span style="color:#8c8c8c;font-style:italic"></span><span style="color:#8c8c8c;font-style:italic">   </span><span style="color:#00627a">ASN1T_DangerousGoodsExtended </span>();<br>} ;</pre>
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
This is the code extract of the sip translation:<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<pre style="background-color:#ffffff;color:#080808;font-family:'JetBrains Mono',monospace;font-size:9.8pt"><span style="color:#0033b3">extern </span><span style="color:#067d17">"C" </span>{<span style="color:#0033b3">static </span>PyObject *<span style="color:#00627a">varget_ASN1T_DangerousGoodsExtended_companyName</span>(<span style="color:#0033b3">void </span>*, PyObject *, PyObject *);}<br><span style="color:#0033b3">static </span>PyObject *<span style="color:#00627a">varget_ASN1T_DangerousGoodsExtended_companyName</span>(<span style="color:#0033b3">void </span>*sipSelf, PyObject *, PyObject *)<br>{<br>    <span style="color:#0033b3">const  </span>::OSUTF8CHAR*<span style="color:#000000">sipVal</span>;<br>     ::ASN1T_DangerousGoodsExtended *<span style="color:#000000">sipCpp </span>= <span style="color:#0033b3">reinterpret_cast</span>< ::ASN1T_DangerousGoodsExtended *>(sipSelf);<br><br>    sipVal = sipCpp->companyName;<br><br>    <span style="color:#0033b3">if </span>(sipVal == SIP_NULLPTR)<br>    {<br>        Py_INCREF(Py_None);<br>        <span style="color:#0033b3">return </span>Py_None;<br>    }<br><br>    <span style="color:#0033b3">return </span>PyBytes_FromString((<span style="color:#0033b3">char </span>*)sipVal);<br>}<br><br><br><span style="color:#0033b3">extern </span><span style="color:#067d17">"C" </span>{<span style="color:#0033b3">static int </span><span style="color:#00627a">varset_ASN1T_DangerousGoodsExtended_companyName</span>(<span style="color:#0033b3">void </span>*, PyObject *, PyObject *);}<br><span style="color:#0033b3">static int </span><span style="color:#00627a">varset_ASN1T_DangerousGoodsExtended_companyName</span>(<span style="color:#0033b3">void </span>*sipSelf, PyObject *sipPy, PyObject *sipPySelf)<br>{<br>    <span style="color:#0033b3">const  </span>::OSUTF8CHAR*<span style="color:#000000">sipVal</span>;<br>     ::ASN1T_DangerousGoodsExtended *<span style="color:#000000">sipCpp </span>= <span style="color:#0033b3">reinterpret_cast</span>< ::ASN1T_DangerousGoodsExtended *>(sipSelf);<br><br>    sipVal = (<span style="color:#0033b3">const unsigned char </span>*)sipBytes_AsString(sipPy);<br><br>    <span style="color:#0033b3">if </span>(PyErr_Occurred() != SIP_NULLPTR)<br>        <span style="color:#0033b3">return </span>-<span style="color:#1750eb">1</span>;<br><br>    sipCpp->companyName = sipVal;<br><br>    sipKeepReference(sipPySelf, -<span style="color:#1750eb">65</span>, sipPy);<br><br>    <span style="color:#0033b3">return </span><span style="color:#1750eb">0</span>;<br>}</pre>
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
If someone has an idea that could help me, I would be greatflul for an answer.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
Regards<br>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
M.T.<br>
</div>
</div>
</body>
</html>