title: Java JNI: Passing multibyte characters from java to c
body: <p>I'm once again messing around with the java natve interface, and I've runned into another interesting problem. I'm sending a filepath to c via jni and then doing some I/O. So the most common chars I have troubles with is <em>'äåö'</em>. Here is a short demo of a program with the exact same problem:</p>
  
  <p><strong>Java:</strong></p>
  
  <pre><code>public class java {
  
    private static native void printBytes(String text);
    static{
      System.loadLibrary("dll");
    }
  
    public static void main(String[] args){
      printBytes("C:/Users/ä-å-ö/Documents/Bla.txt");
    }
  }
  </code></pre>
  
  <p><strong>C:</strong></p>
  
  <pre><code>#include "java.h"
  #include &lt;jni.h&gt;
  
  JNIEXPORT void JNICALL Java_java_printBytes(JNIEnv *env, jclass class, jstring text){
    const jbyte* text_input = (*env)-&gt;GetStringUTFChars(env, text, 0);
    jsize size = (*env)-&gt;GetStringUTFLength(env, text);
    int i = 0;
    printf("%s\n",text_input);
    (*env)-&gt;ReleaseStringUTFChars(env, text, text_input);
  }
  </code></pre>
  
  <p><strong>Output:</strong>
  C:/Users/├ñ-├Ñ-├Â/Documents/Bla.txt</p>
  
  <p>This is <em>NOT</em> my desired result, I would like it to output the same string as in java.</p>