Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

converting Native Characters to Unicode

 
Ranch Hand
Posts: 157
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
Brace yourself while corporate america tries to sell us its things. Some day they will chill and use tiny ads.
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic