• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Reading hindi text from excel file and getting its corresponding unicode

 
varsha rao
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20512
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
varsha rao
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic