title: How do I apply the conversion from charCodeAt to C # here?
body: <p>So I've already found posts on this topic, but that didn't really help me. On the one hand, I have tried something like this, for example, but it is not quite right in my case**(C#)**.</p>
  <pre><code>   string temp;
  
          foreach (var a in chaine)
             temp = ( Convert.ToUInt16(a).ToString(&quot;X4&quot;));
  
          for (j = 0; j &lt; intlenght; j+= 1)
          {
              arrayData[j + 1] = temp; 
  }
  </code></pre>
  <p>Why I think it doesn't really work is that my starting form looked a little different than the examples and I'm not really familiar with JavaScript. My starting shape looks like this**(javaScript)**:</p>
  <pre><code>for (j = 0; j &lt; intlenght; j+= 1)
          {
              arrayData[j + 1] = x.charCodeAt(j) - 32;
  }
  </code></pre>
  <p>the <strong>x</strong> in this case it is actually</p>
  <pre><code>var x = document.getElementById (&quot;textIn&quot;). value;
  </code></pre>
  <p>but in my method I have a string return value instead of the <strong>X</strong></p>
  <p>so how can i correctly get the</p>
  <blockquote>
  <p>arrayData [j + 1] = x.charCodeAt (j) - 32;</p>
  </blockquote>
  <p>translate in c #. In the end I need this in my method for Code128 encoder</p>
  <p><strong>EDIT for better Understanding:</strong></p>
  <p>So I have a TextBlock in my window, but there is a text in it in a barcode 128 font. However, this barcode cannot yet be read. So what I want to do is add the additional characters of the barcode so that at the end you can scan this barcode with a scanning program. To do that I come across this Stack Overflow answer: <a href="https://stackoverflow.com/a/60363928/17667316">https://stackoverflow.com/a/60363928/17667316</a></p>
  <p>However, the problem was with the question that the code is in JavaScript and not in C #. Since I've only found solutions where it works with libaries and nuggets (which I want to work around) I tried to convert this javaScript code into C #. I come across lines like this(<strong>javaScript</strong>):</p>
  <pre><code>arrayData[j + 1] = x.charCodeAt(j) - 32;
  </code></pre>
  <p>I didn't find a solution to this as I did this Javascript code:</p>
  <pre><code>    var buttonGen = document.getElementById(&quot;btnGen&quot;);
  buttonGen.onclick = function () {
    var x = document.getElementById(&quot;textIn&quot;).value;
    var i, j, intWeight, intLength, intWtProd = 0, arrayData = [], fs;
    var arraySubst = [ &quot;Ã&quot;, &quot;Ä&quot;, &quot;Å&quot;, &quot;Æ&quot;, &quot;Ç&quot;, &quot;È&quot;, &quot;É&quot;, &quot;Ê&quot; ];
  
  /*
   * Checksum Calculation for Code 128 B
   */
    intLength = x.length;
      arrayData[0] = 104; // Assume Code 128B, Will revise to support A, C and switching.
      intWtProd = 104;
      for (j = 0; j &lt; intLength; j += 1) {
              arrayData[j + 1] = x.charCodeAt(j) - 32; // Have to convert to Code 128 encoding
              intWeight = j + 1; // to generate the checksum
              intWtProd += intWeight * arrayData[j + 1]; // Just a weighted sum
      }
      arrayData[j + 1] = intWtProd % 103; // Modulo 103 on weighted sum
      arrayData[j + 2] = 106; // Code 128 Stop character
    chr = parseInt(arrayData[j + 1], 10); // Gotta convert from character to a number
    if (chr &gt; 94) {
      chrString = arraySubst[chr - 95];
    } else {
      chrString = String.fromCharCode(chr + 32);
    }
    
    // Change the font-size style to match the drop down
    fs = document.getElementsByTagName(&quot;option&quot;)[document.getElementById(&quot;selList&quot;).selectedIndex].value;
    document.getElementById(&quot;test&quot;).style.fontSize = fs  + 'px';
    
    document.getElementById(&quot;check&quot;).innerHTML =
      'Checksum = ' + chr + ' or character ' + // Make It Visual
      chrString + ', for text = &quot;' + x + '&quot;';
    
    document.getElementById(&quot;test&quot;).innerHTML =
      'Ì' + // Start Code B
      x + // The originally typed string
      chrString + // The generated checksum
      'Î'; // Stop Code
  }
  </code></pre>
  <p>Can convert into a working C # code.</p>