• Post Reply Bookmark Topic Watch Topic
  • New Topic

Accent Character in File Name(not data inside it)

 
amol deshpande
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Im facing a typical problem where the name of file contains an accent char.
Ex, file name in current dir r╩.bat. Now if I create a File object giving this name, Java cannot read it as r╩.bat, and File.exists() gives false. However, if I get a list of files in current directory, it replaces the accent character to some different one, we can get its name by File.getName().

Given the situation that user would like to type in the name of File( and he knows what it is), how do we pass a name to file object taking parameter from Html form?

Any help is appreciated.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Make sure that the encoding of the web page is one that can handle the character in question (e.g., UTF-8). Then the form will be submitted using that encoding as well, in which case the parameter should arrive on the server unharmed, and you can use it in the File constructor.

if I get a list of files in current directory, it replaces the accent character to some different one

If you print out the names to the console, it might be that you see funny characters, because the console can't handle them, but the names themselves should be OK.

(There is a related problem on Mac OS with composed/uncomposed accented characters, which Greg Guerins MacBinary Toolkit solves via its AccentComposer class.)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!