• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

converting Native Characters to Unicode

 
vikasids sharma
Ranch Hand
Posts: 157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all

I need to convert the characters entered by user in any language through GUI Interface into Unicode before it is saved to a property file and again want to convert it into native(entered earlier by user) characters before displaying to user . Plese let me know the solution for this conversion. I m using Struts .

Thanks
Vikasids
 
kapil Gupta
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use nativetoascii command available in the JDK\bin folder. This command converts the native characters into Unicode. But i think it works for characters written in file. Am not sure if it can be used for characters entered on the UI.
 
vikasids sharma
Ranch Hand
Posts: 157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks kapil
First of all i cannot make use of that batch file using java class. I mean Is it possible to run batch file through java program? Secondly user enters native characters , i have to capture those characters from UI so cannot use IO streams. I have to get those, convert to ASCII and then using IO have to write in Properties File.

Originally posted by kapil Gupta:
You can use nativetoascii command available in the JDK\bin folder. This command converts the native characters into Unicode. But i think it works for characters written in file. Am not sure if it can be used for characters entered on the UI.
 
Raminder Singh
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
On Running this code:
import java.io.*;

class execInput
{
public static void main(String Argv[])
{
try {
String ls_str;
Process ls_proc = Runtime.getRuntime().exec("native2ascii -reverse inFile.txt outFile.txt");
DataInputStream ls_in = new DataInputStream(ls_proc.getInputStream());
try {
while ((ls_str = ls_in.readLine()) != null)
{
System.out.println(ls_str);
}
} catch (IOException e)
{
System.exit(0);
}
} catch (IOException e1)
{
System.err.println(e1);
System.exit(1);
}
System.exit(0);
} //end of main
} // end of class
----------------------
if infile.txt - \u0061b\u0063 then outFile.txt have - abc.

you can use it.

But when i put \u0A15\u0A16(Gurmukhi/punjabi langauage) in inFile.txt get outFile as ??

i have 3 queries:
1) do i need to install punjabi fonts?
2) why we have to use -reverse to run native2ascii here. it should be without this option.
3) how to change encoding via -encoding


it may coz
 
vikasids sharma
Ranch Hand
Posts: 157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Raminder
"Runtime.getRuntime().exec("native2ascii -reverse inFile.txt outFile.txt");" works fine when u need to read a text file but in my situation i need to capture from user input which is not in form of text file rather will be capturing through request after submission of page.

Originally posted by raminder singh:
hi,
On Running this code:
import java.io.*;

class execInput
{
public static void main(String Argv[])
{
try {
String ls_str;
Process ls_proc = Runtime.getRuntime().exec("native2ascii -reverse inFile.txt outFile.txt");
DataInputStream ls_in = new DataInputStream(ls_proc.getInputStream());
try {
while ((ls_str = ls_in.readLine()) != null)
{
System.out.println(ls_str);
}
} catch (IOException e)
{
System.exit(0);
}
} catch (IOException e1)
{
System.err.println(e1);
System.exit(1);
}
System.exit(0);
} //end of main
} // end of class
----------------------
if infile.txt - \u0061b\u0063 then outFile.txt have - abc.

you can use it.

But when i put \u0A15\u0A16(Gurmukhi/punjabi langauage) in inFile.txt get outFile as ??

i have 3 queries:
1) do i need to install punjabi fonts?
2) why we have to use -reverse to run native2ascii here. it should be without this option.
3) how to change encoding via -encoding


it may coz
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic