title: Objective-C character encoding - Change char to int, and back
body: <p>Simple task: <strong>I need to convert two characters to two numbers, add them together and change that back to an character.</strong><br>
  What I have got: (works perfect in Java - where encoding is handled for you, I guess):</p>
  
  <pre><code>int myChar1 = (int)([myText1 characterAtIndex:i]);
  int myChar2 = (int)([myText2 characterAtIndex:keyCurrent]);
  int newChar = (myChar1 + myChar2);
  //NSLog(@"Int's %d, %d, %d", textChar, keyChar, newChar);
  char newC = ((char) newChar);
  
  NSString *tmp1 = [NSString stringWithFormat:@"%c", newC];
  NSString *tmp2 = [NSString stringWithFormat:@"%@", newString];
  newString = [NSString stringWithFormat:@"%@%@", tmp2, tmp1]; //Adding these char's in a string
  </code></pre>
  
  <p>The algorithm is perfect, but now I can't figure out how to implement encoding properties. I would like to do everything in UTF-8 but have no idea how to get a <code>char</code>'s UTF-8 value, for instance. And if I've got it, how to change that value back to an <code>char</code>.<br>
  The <code>NSLog</code> in the code outputs the correct values. But when I try to do the opposite with the algorithm (I.e. <code>-</code> the values) then it goes wrong. It gets the wrong character value for weird/odd characters.</p>