R
rudy.martono
Hi,
I am writing a JNI function that receives jstring filename and return
the created date based on stat function.
The issue is when I am supposed to handle a Unicode filename.
For example:
Εχ.txt ==> "\u0395\u03c7.txt"
Please correct me if I am wrong.
function header:
JNIEXPORT jlong JNICALL Java_getAccessedDate
(JNIEnv * env, jclass obj, jstring filename)
using the GetStringUTFRegion, I am able to translate the jstring
filename into UTF-8 format.
(*env)->GetStringUTFRegion(env, filename, 0, len, rtn);
where
filename is the parameter jstring
rtn is (char *)
and len is (*env)->GetStringLength(env, filename)
When I print it out, it looks like that it gives the right value.
But I double check the value back by using fopento see whether the file
exists or not , and it returns NULL.
Therefore, I assume stat will return 0, but it returns 724466048.
I am still not familiar with Unicode or UTF-8.
Does UTF-8 need 2 bytes per character?
If that is true, then I should use wchar_t instead of char, _wfopen (to
detect whether the file exists), and _wstat (to get the file's info).
Thank you,
Rudy
I am writing a JNI function that receives jstring filename and return
the created date based on stat function.
The issue is when I am supposed to handle a Unicode filename.
For example:
Εχ.txt ==> "\u0395\u03c7.txt"
Please correct me if I am wrong.
function header:
JNIEXPORT jlong JNICALL Java_getAccessedDate
(JNIEnv * env, jclass obj, jstring filename)
using the GetStringUTFRegion, I am able to translate the jstring
filename into UTF-8 format.
(*env)->GetStringUTFRegion(env, filename, 0, len, rtn);
where
filename is the parameter jstring
rtn is (char *)
and len is (*env)->GetStringLength(env, filename)
When I print it out, it looks like that it gives the right value.
But I double check the value back by using fopento see whether the file
exists or not , and it returns NULL.
Therefore, I assume stat will return 0, but it returns 724466048.
I am still not familiar with Unicode or UTF-8.
Does UTF-8 need 2 bytes per character?
If that is true, then I should use wchar_t instead of char, _wfopen (to
detect whether the file exists), and _wstat (to get the file's info).
Thank you,
Rudy