I have found a solution from a forum.
It seems that I need to do memcpy.
wchar_t* getFilename8(jstring filename, JNIEnv * env){
...
...
filename8 = (*env)->GetStringChars( env, filename, NULL );
_wrtn = (wchar_t*)malloc(sizeof(wchar_t)*len+1);
memcpy(_wrtn, filename8, sizeof(wchar_t)*len)...
Thank you, Salem.
I have tried it and it works too.
But in the code, you write
wchar_t fn1[] = L"file\u0395\u03c7.txt";
Is there any way to pass it as variable?
For example:
let
filename = "file\u0395\u03c7.txt";
and
wchar_t fn1[] = L(filename);
The problem is filename is a value pass to a...
sorry, another typo.
i write "\u0395\u03c7" since the two characters are converted into ?? after i am posting it to the forum.
In the file system, it looks like
c:\temporary_test\sample_test\??.txt
the print looks like
c:\temporary_test\sample_test\Εχ.txt
Oh ya that's a typo.
I believe that I am at the right directory.
the fullpath is
"c:\temporary_test\sample_test\\u0395\u03c7.txt.txt"
The issue that is still bugging me is the return value from stat.
As I mention before, I use fopen to detect the existence of the file. If it returns NULL...
I have changed the code so that it checks the return value from stat(). But still, it returns 12/15/1992 04:34:08....
When I try to detect the file using fopen(), it returns NULL.
Somehow stat() returns 724466048 not 0.
I have also printed the value of rtn, and it shows the right name.
I am...
I am running it on windows.
filename: "\u0395\u03c7.txt"
I am sorry. I did not notice that the 2 characters are translated as ??.
JNIEXPORT jlong JNICALL Java_getAccessedDate
(JNIEnv * env, jclass obj, jstring filename){
struct _stat statfile;
char* rtn = getFilename8(filename, env)...
I have a filename with UTF-8 encoded characters, and I am trying to grab the date created from stat().
For example:
the filename is ??.txt
I manage to get the correct filename using WideCharToMultiByte(), but stat() gives the wrong value.
the correct value of date created: 8/4/2006 10:35:38...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.