aspose file tools*
The moose likes Java in General and the fly likes converting Native Characters to Unicode Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "converting Native Characters to Unicode" Watch "converting Native Characters to Unicode" New topic
Author

converting Native Characters to Unicode

vikasids sharma
Ranch Hand

Joined: Aug 01, 2003
Posts: 157
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


Thanks
Vikas Sharma
SCJP(1.4)
kapil Gupta
Ranch Hand

Joined: Dec 17, 2001
Posts: 89
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

Joined: Aug 01, 2003
Posts: 157
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

Joined: Mar 01, 2002
Posts: 72
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

Joined: Aug 01, 2003
Posts: 157
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
 
 
subject: converting Native Characters to Unicode