title: How to convert a string to UTF-16?
body: <p>I am converting the below object code to java, but the java code does not  give me the same result as this code</p>
  <pre><code>NSData *inputData = [pm dataUsingEncoding:NSUTF16LittleEndianStringEncoding];
  NSString *encodedString = [inputData base64EncodedString];
  pm = [IFunctions replaceString:encodedString replaceChar:@&quot;=&quot; replaceWithChar:@&quot;-&quot;];
  </code></pre>
  <p>Java code:</p>
  <pre><code>String s_decoded = new String(pm.getBytes(), &quot;UTF-16LE&quot;);
  pm = Base64.encode(s_decoded.getBytes()).toString().replace(&quot;=&quot;, &quot;-&quot;);
  </code></pre>