10 messages in net.java.dev.jna.usersRe: [jna-users] String related questions
FromSent OnAttachments
Bartko ZoltanJul 12, 2007 4:49 am.java, .java
Bartko ZoltanJul 12, 2007 6:08 am 
Wayne MeissnerJul 12, 2007 6:09 am 
Timothy WallJul 12, 2007 8:03 am 
Timothy WallJul 12, 2007 8:38 am 
Bartko ZoltanJul 13, 2007 12:10 am 
Bartko ZoltanJul 13, 2007 1:05 am 
Timothy WallJul 13, 2007 7:11 am 
Oleksandr MaksymchukOct 22, 2007 4:25 am 
Timothy WallOct 22, 2007 6:34 am 
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] String related questionsActions...
From:Timothy Wall (twal@dev.java.net)
Date:Jul 13, 2007 7:11:06 am
List:net.java.dev.jna.users

On Jul 13, 2007, at 3:11 AM, Bartko Zoltan wrote:

As to the conversion: When using the Hunspell spell-checking library, the following procedure should be observed: 1. initialize the spell checker with the correct dictionary 2. get the encoding of the dictionary 3. check the spelling of the words sent to the library in the correct encoding 4. do some final cleanup.

Now, how do I do step 3 (I mean, converting the text I want to check to the correct encoding)?

a) change the Java platform default encoding to UTF-8 (google for this, I don't remember off the top of my head, file.encoding or something like that) b) explicitly convert strings to NUL-terminated byte arrays with a static function and pass the byte array instead of a String:

byte[] convert(String s) { byte[] buf = s.getBytes("UTF8"); byte[] out = new buf[buf.length+1]; System.arraycopy(...); out[out.length-1] = 0; return out; }

When you get it working, we can look at making it easier to force JNA to use a specific encoding (assuming "A" is not reliable or is undesirable).