title: Kotlin .toInt() returns ASCII value
body: <p>I'm working on a 3 track step sequencer, and the spinners for sample selection are causing me some trouble. The following code is executed when a saved pattern is loaded to set the correct samples. </p>
  
  <pre><code>for ((index, j) in spinners.withIndex()){
     val item = loadingPattern[(48+index)]
     Log.i("item", item.toString())
     Log.i("int", item.toInt().toString)
     j.setSelection(item.toInt())
  }
  </code></pre>
  
  <p>The array "spinners" contains 3 spinners with 5 entries each. "loadingPattern" is a string that contains the pattern information. The last three characters are integers corresponding to the spinner position. When the spinner selections are as the following:</p>
  
  <p>Spinner 1: Selected item index 0
  Spinner 2: Selected item index 3
  Spinner 3: Selected item index 4</p>
  
  <p>The log "item" prints exactly these values. The log "int" however prints 48+index, so in this case 48, 50, 52. Since the toInt() function is also called on the value parsed to the .setSelection() function, this exception is triggered:</p>
  
  <p><code>java.lang.ArrayIndexOutOfBoundsException: length=2; index=48</code></p>
  
  <p>If anyone has an idea why this is happening, I would be very happy to know. Thank you all so much! I love this communtiy! </p>
  
  <p>edit:
  If the pattern is programmed like this:
  <a href="https://i.stack.imgur.com/kZvFl.png" rel="nofollow noreferrer">typical pattern</a></p>
  
  <p>The "patternString" is the following:
  101010101010101010000000100000001000100010001000420</p>
  
  <p>active steps are represented by 1, the others by 0. The last 3 digits are the spinner positions. Maybe this will help :)</p>
  
  <p>Edit 2:
  I just found this question: <a href="https://stackoverflow.com/q/52399443/12092346">I have String with numbers when getting the char from string it shows &#39;0&#39;48 in kotlin. How to get the char alone in kotlin</a>
  And there they say that the ASCII value of 0 is 48. <strong>This means that toInt() probably returns the ASCII value of 0. But why is that and how can I get just the normal integer?</strong></p>