Solve the problem that manzana supports Chinese (or utf8) operations
At the beginning, I studied for a long time and focused on conversion of character encoding. I used many methods to convert the Chinese file names passed back by itunesmobiledevice to utf8 or gb2312. It is found that there is no problem in converting gb to utf8, but an error occurs when utf8 to gb. When the number of characters in the string to be converted is an odd number, a question mark "?" is often displayed. Or something. This problem does not occur if it is an even number. I found a lot of information on the internet and found several people had this problem. One of them spent a year, but they did not solve it. My heart is chilling, and I don't need to think about it any more when I get started. After one day and one night, I finally gave up. I think there is a loss of data when utf8 is converted to gb. Because utf8 is large, this problem cannot be solved.
There was nothing to do a few days ago and I began to think about it again. This time I started to study the functions of itunesmobiledevice. I found that manzana passed the itunesmobiledevice function with the string parameter.
[Dllimport (dllname, charset = charset. ansi, callingconvention = callingconvention. cdecl)]
Unsafe public extern static int afcfileinfoopen (void * conn, string path, ref void * dict );
I think the path passed in is byte [], so itunesmobiledevice should be recognizable. I tried it. The result is OK !!!! So excited !!!!!!!!!! Later, I changed all other string parameters to byte [], and then my file management function was done. The following is a function.
Unsafe public static int afcdirectoryread (void * conn, void * dir, ref byte [] buffer)
{
Int ret;
Void * ptr = null;
Ret = afcdirectoryread (conn, dir, ref ptr );
If (ret = 0) & (ptr! = Null ))
{
Intptr ipptr = new intptr (ptr );
Arraylist bufferarray = new arraylist ();
Int curr = 0;
While (true)
{
Byte tmpbyte = marshal. readbyte (ipptr, curr );
If (tmpbyte! = 0)
{
Bufferarray. add (tmpbyte );
Curr ++;
}
Else
{
Break;
}
}
Buffer = (byte []) bufferarray. toarray (typeof (byte ));
}
Else
{
Buffer = null;
}
Return ret;
}
I come to the conclusion that when using c # to call an unmanaged dll, it is best to use byte [] instead of string to operate the characters.
Now I can use my class to operate the file system on ios. Next, I will add the function of copying the converted ipa directly to the installous directory in pxlipafactory.