• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

String format to create directory in Unix

 
Ranch Hand
Posts: 37
Eclipse IDE Oracle
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I have an issue in writing a file to a server path.
The problem is like this:

I have a job that runs in the Unix environment to get an extract and write that to a file in the server location. The path that I have configured to write the file ..say "abc.csv" is in
/projects/distrib/extracts/XXX/éxtract.

The problem here is when the file is been created by the job the final folder is created as ?xtract. The é is been converted. But if I try to create the folder with same name manually in the same machine through file zilla the folder gets created.

Could you please help me to identify an correct the issue.

I had tried MimeUtility.encodeText("éxtract"); But didnt work..it encoded the text to something else.

Regards
 
Nirmal Mukundan
Ranch Hand
Posts: 37
Eclipse IDE Oracle
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Does any one have the solution to this.
I tried to put the following code

logger.info("Default Charset=" + Charset.defaultCharset()); -- output is US-ASCII

String path = "/projects/distrib/extracts/XXX/éxtract";
byte[] bytes3 = path.getBytes("UTF-8");
System.out.println("UTF-8 decoded: "+new String(bytes3)); -- output is /projects/distrib/extracts/XXX/?xtract

Please help
 
Ranch Hand
Posts: 423
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is your job is a java program ?
How this job is fired, by cron ?
Is the file that contains the directory name is encoded in utf8 or is a plain ascii or something else ?
What is a value of LANG variable in the execution environment of your job ?
 
Nirmal Mukundan
Ranch Hand
Posts: 37
Eclipse IDE Oracle
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The program is a java program and is called from a swing client. This piece of code runs in the Unix environment.

When I gave System.getProperty("file.encoding") -- out put is ANSI_X3.4-1968

LANG value is C
 
Ireneusz Kordal
Ranch Hand
Posts: 423
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Nirmal Mukundan wrote:The program is a java program and is called from a swing client. This piece of code runs in the Unix environment.

When I gave System.getProperty("file.encoding") -- out put is ANSI_X3.4-1968

LANG value is C



C and ANSI_X3.4-1968 is a plain ASCII encoding, it doesn't have é character
Check which code pages are supported by your system, a command locale -a writes all available locales,
use one that supports utf8.


You can test which settings are OK with this simple java program:


 
Nirmal Mukundan
Ranch Hand
Posts: 37
Eclipse IDE Oracle
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ireneusz,

Thanks for the reply. Well we have moved to the new Linux machines recently. So could it be that the LANG settings have not been set properly.

Regards
Nirmal
 
Nirmal Mukundan
Ranch Hand
Posts: 37
Eclipse IDE Oracle
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ireneusz,

Thanks for the reply. Well we have moved to the new Linux machines recently. So could it be that the LANG settings have not been set properly.
Today I tried with a sample program to create a directory in the same machine. Before executing the program, I did export LANG=fr_FR and this worked fine.

But I think this wont be right encoding..Is it?

Regards
Nirmal
 
Ireneusz Kordal
Ranch Hand
Posts: 423
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

it seems that the job doesn't inherit the environment from the calling application and uses ANSI_X3.4-1968 as default charset.
Try to launch this job from the swing application with command: java -Dfile.encoding=utf8 jobname or java -Dfile.encoding=ISO-8859-1 jobname,
this should force jvm to use the proper encoding.

Regards.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic