This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

converting unsigned char * to jcharArray in JNI  RSS feed

 
Kedar Saravate
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am doing JNI programming.
I have one unsigned char * tempdata as an OUT parameter.
I want to convert this unsigned char * temdata to jcharArray.
so it will be accessible to me.
how can i do it?
please give a proper coding steps. means Source code.
or mail me source code at [elided.]

thanks in advance.
[ June 07, 2007: Message edited by: Ernest Friedman-Hill ]
 
Peter Chase
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JNI is usually discussed in Other Java APIs forum. Also, it is against JavaRanch convention to request private conversations: UseTheForumNotEmail. Please don't do that.

Before your question can be answered, you have to tell us how your char* data is encoded. Unlike Java, there is no fixed definition for the encoding of text, so you have to know.

It might be 7-bit ASCII. If it is, you can just cast each char to a jchar.

It might be UTF-8. It it is, you certainly cannot just cast. But there are JNI functions like NewStringUTF() that will help in that case.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!