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 'äåö'. Here is a short demo of a program with the exact same problem:
Java:
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");
}
}
C:
#include "java.h"
#include <jni.h>
JNIEXPORT void JNICALL Java_java_printBytes(JNIEnv *env, jclass class, jstring text){
const jbyte* text_input = (*env)->GetStringUTFChars(env, text, 0);
jsize size = (*env)->GetStringUTFLength(env, text);
int i = 0;
printf("%s\n",text_input);
(*env)->ReleaseStringUTFChars(env, text, text_input);
}
Output: C:/Users/├ñ-├Ñ-├Â/Documents/Bla.txt
This is NOT my desired result, I would like it to output the same string as in java.