11 messages in net.java.dev.jna.usersRe: [jna-users] char* versus wchar_t ...
FromSent OnAttachments
Dale...@coats.comMay 13, 2008 5:17 am 
Timothy WallMay 13, 2008 6:00 am 
Timothy WallMay 13, 2008 6:05 am 
Dale...@coats.comMay 13, 2008 8:55 am 
Timothy WallMay 13, 2008 9:06 am 
Dale...@coats.comMay 13, 2008 11:46 am.zip
Daniel KaufmannMay 13, 2008 5:16 pm 
Dale...@coats.comMay 14, 2008 5:02 am 
Timothy WallMay 14, 2008 6:10 am 
Dale...@coats.comMay 15, 2008 6:33 am 
Timothy WallMay 15, 2008 12:38 pm 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: [jna-users] char* versus wchar_t * in a StructureActions...
From:Timothy Wall (twal@dev.java.net)
Date:May 13, 2008 6:00:36 am
List:net.java.dev.jna.users

On May 13, 2008, at 8:18 AM, Dale@coats.com wrote:

I worked through many theories (ByteBuffer, WString, Structure.ByValue, Pointer, etc) but nothing I've tried got me very far with being able to supply a wchar_t into a Structure. I figure that one of the things I've been trying will work if I just get some more implementation details right.

'x' shows as the "tool tip" if I do this:

public static class NOTIFYICONDATA extends Structure { public int cbSize; public HANDLE hWnd; // HWND.setPointer(aJWindow) keeps XP happy, btw! public int uID; public int uFlags; public int uCallbackMessage; public HANDLE hIcon; public char szTip = 'x'; }

Nominally, a wide native string, "const wchar_t *" is represented in Java by WString. Otherwise, Java "char" maps to native "wchar_t".

If you look at the W32API definitions in JNA, though, you'll see that you can automagically convert String into "const wchar_t *" by using the DEFAULT_OPTIONS supplied for initializing a library. These options install a type converter and function mapper that automatically handle windows ascii vs unicode modes.