title: Convert jcharArray to String with right encoding jni
body: <p>I have native method that return array of files in directory.
  public static native char[][] scan(String path);
  I can't return array of strings because if file has invalid encoding- everything crashes
  The problem is correctly convert char[] to String on java side, when i try new String(chars); i get unprintable string (invalid). Please correct me.</p>
  
  <p>Here is example of output (If method return String[])</p>
  
  <p><code>Array.toString(scan("/storage/"));</code> -> [/storage/sdcard1, /storage/sdcard0]</p>
  
  <p>Here is if method return char[][];</p>
  
  <pre><code>char[][] chars = scan("/storage/");
  String[] stringArray = new String[char.length];
  for(int i = 0; i &lt; chars.length; i++){
      stringArray[i] = new String(char[i]);
  }
  Arrays.toString(stringArray); -&gt; //unprintable symbols [����������爀条⽥摳慣摲쉮R����,����������爀条⽥摳慣摲쉮R����]
  </code></pre>
  
  <p>What happens on C side: if method return String[]</p>
  
  <pre><code>jobjectArray scan(JNIEnv *env, jclass cls,jstring jpath){
      std::vector&lt;std::string&gt; data;//contains some strings
      unsigned int size = data.size();
      jobjectArray ret = env-&gt;NewObjectArray(size,env-&gt;FindClass("java/lang/String"),NULL);
      for (unsigned int i = 0; i &lt; size; i++){
              env-&gt;SetObjectArrayElement(ret,i,env-&gt;NewStringUTF(data.at(i).c_str()));
          }
      return ret;
  }
  </code></pre>
  
  <p>What happens on C side: if method return char[][];</p>
  
  <pre><code>jobjectArray scan(JNIEnv *env, jclass cls,jstring jpath){
          std::vector&lt;std::string&gt; data;//contains some strings
          unsigned int size = data.size();
          jobjectArray ret = env-&gt;NewObjectArray(size, env-&gt;FindClass("[C"), NULL);
          for (unsigned int i = 0; i &lt; size; i++){
                  env-&gt;SetObjectArrayElement(ret,i,env-&gt;NewStringUTF(toChar(env,data.at(i))));
              }
          return ret;
      }
      jcharArray toChar(JNIEnv *env, string string) {
          unsigned int n=0;
          const char* p = string.c_str();
          while(*p++){
              n++;
          } if(n&lt;=0)
              return NULL;
  
          jcharArray arr = env-&gt;NewCharArray(n);
          env-&gt;SetCharArrayRegion(arr,0,n, (jchar*)p);
          return arr;
      }
  </code></pre>