|
|
Re: calling all dnd experts... [message #437898 is a reply to message #437873] |
Fri, 11 June 2004 16:54 |
Matthew Hatem Messages: 47 Registered: July 2009 |
Member |
|
|
Thanks for the help. Actually for the name I had to do the following.
byte[] bytes = new byte[size];
byte[] finalBytes = new byte[size+2];
finalBytes[0] = (byte)0xFF; finalBytes[1] = (byte)0xFE;
readIn.read(bytes);
System.arraycopy(bytes, 0, finalBytes, 2, bytes.length);
datum.sFileName = new String(finalBytes, "UTF-16");
Seems I needed the 0xFF and 0xFE headers.
Simone Gianni wrote:
> Matthew Hatem wrote:
>
>> I'm trying build support for dragging attachments out of an email
>> client into my Eclipe RCP application.
>>
>> I've extended ByteArrayTransfer and nativeToJava am basically going
>> over all the bytes as needed and writing them to a temp file. This
>> all works well and good, only problem is I'm having difficulty a)
>> getting file/attachment count and b) getting the file name.
>>
>> a) When I get to the bytes that represent the file count, basically
>> just a DWORD, the bytes look like a copy of the raw memory and
>> readInt() doesn't handle the byte/word swapping. Is there a utiltiy
>> method I can use to help me out here?
>
>
> Not in java itself AFAIK. But you should be able to do it with a few
> "<<" and ">>" (shift left and shift right) operations.
>
>>
>> b) When I get to the collection of bytes that represent the file name,
>> the bytes were literally changed into chars... UNICODE chars to be
>> precise... 2 bytes per character. "ASCII" characters are their
>> character code with a 0 as the 2nd byte. Is there some MultiByteToXXX
>> utility function I can call to help me here?
>
>
> byte[] namebytes = ....
> String name = new String(namebytes, "UTF-16");
>
> Hope this helps,
> Ciao,
>
> Simone Gianni
|
|
|
|
Powered by
FUDForum. Page generated in 0.03118 seconds