File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes japanese character encoding Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "japanese character encoding" Watch "japanese character encoding" New topic
Author

japanese character encoding

nuthan kumar
Ranch Hand

Joined: Feb 14, 2006
Posts: 47
Hi All,
I am getting string value from one FTP server (this holds name of the file, and we are using Apache FTP API to get filenames), while creating a file in local maching with same name its not creating with japanese characters, its puting some junk charcters. Please help me in creating file with same name. I am using following code to get file name and to create new file

String sFilename = ftpFile.getName(); // ftpFile is apache FTPFile object
String jpName = new String(sFilename.getBytes("UTF-8"),Charset.forName("SJIS"));
File targetFile = new File(jpName);
targetFile.createNewFile();

but this code is not working properly

Nuthan
Alan Moore
Ranch Hand

Joined: May 06, 2004
Posts: 262
You shouldn't need to do any conversions. The FTP client should have converted the name to a valid Java string, and the File class should convert that to the encoding that's expected by the operating system.

What kind of garbage characters are you seeing? If it's question marks (?) you have an encoding problem, but if you see little boxes, it means the font you're using doesn't support those characters.

By the way, never do this: Unless the string consists entirely of seven-bit ASCII characters, that command is guaranteed to produce garbage. And if it is pure ASCII, the command will have no effect.
nuthan kumar
Ranch Hand

Joined: Feb 14, 2006
Posts: 47
i am seeing ? in the string, i tried by removing encoding/decoding also. still its not wroking properly
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Originally posted by nuthan kumar:
i am seeing ? in the string, i tried by removing encoding/decoding also. still its not wroking properly


What do you view the String in? Does it support these Japanese chacacters?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
nuthan kumar
Ranch Hand

Joined: Feb 14, 2006
Posts: 47
actual file name 1-計画.tif and while trying to print that name its printing 1-??.tif
David Balažic
Ranch Hand

Joined: May 15, 2008
Posts: 86
Print the name in some SWING GUI element (like JButton or JLabel), as the Windows command prompt does not support Unicode.
Also print the string after each manipulation, to see where it breaks.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: japanese character encoding