wood burning stoves 2.0*
The moose likes Other JSE/JEE APIs and the fly likes Reading hindi text from excel file and getting its corresponding unicode Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Reading hindi text from excel file and getting its corresponding unicode" Watch "Reading hindi text from excel file and getting its corresponding unicode" New topic
Author

Reading hindi text from excel file and getting its corresponding unicode

varsha rao
Greenhorn

Joined: Mar 06, 2006
Posts: 26
HI ,

I have a requirement where i have to read hindi text from an excel sheet and write it onto a app_hi.properties file. The problem is in the hindi propeties file we need to have the unicode of the hindi word for it to get reflected on the screen and i am not able to do this. I am able to read the hindi text from excel but i dont know how to convert it to unicode. When i run mhy code in debug mode or try to print the hindi string , only a set of ??? are displayed.

Can anyone please help me with this.

I am not sure if this is the right forum for this question. Please let me know if i have posted it in the wrong place.

thanks
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19649
    
  18

The console can't handle anything that's not ASCII most of the time. Does it work if you write to a text file instead, then open that text file in a unicode-able text editor?


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
varsha rao
Greenhorn

Joined: Mar 06, 2006
Posts: 26
I am able to read the hindi code from the excel sheet , but i need to convert the hindi characters to the corresponding unicode.

My prog should read hindi code from excel and write the corresponding unicode to a properties file.


Excel sheet data Properties file data

पुन:आरंभ करें read this and write --> \u0905\u0928\u0941\u0930\u094b\u0927\u002


There is a tool called unipad which provides the unicode for hindi words but do we have any api's in java to use any such tool?

Is there any way for achieving this ?
varsha rao
Greenhorn

Joined: Mar 06, 2006
Posts: 26
Hi all,

I found a solution for this. In Java5.0 the Character class provides methods which will return the code point for a given char[] array

codePointAt(char[] a, int index) ;

Using this method we can get the Unicode for a String in any Language which can be displayed on the browser

// here is the method for the same "value" is the String in hindi (or any other) Language

public static String getUnicode(String value)
{

StringBuffer testBuffer = new StringBuffer();
char[] test = value.toCharArray();

if(test != null)
{
int size1 = test.length;


for(int j = 0 ; j < size1;j++)
{
testBuffer.append("&#");
testBuffer.append(Character.codePointAt(test, j));
testBuffer.append(";");
}


}

return testBuffer.toString();
}

This method will return you the correspoding unicode in dec which you can write to a properties file and use the samefor display

Reference : http://en.wikipedia.org/wiki/Unicode_and_HTML


Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Reading hindi text from excel file and getting its corresponding unicode
 
Similar Threads
Do Jmeter support utf charaters
Unicode and Property files
Insert Hindi text in postgres database with java
Unicode text editor
java trim function is not working when reading excel data