Allen, Michael B (RSCH) Michael_B_Allen at
Fri May 3 03:38:59 GMT 2002

> -----Original Message-----
> From:	Ali Hasnain Baqri [SMTP:ali.baqri at]
> Sent:	Thursday, May 02, 2002 11:23 PM
> To:	Allen, Michael B (RSCH)
> Cc:	'Urban Widmark'; smb-clients at
> Subject:	Re: smbclient/solaris/smbclient
> Hi Allen,Urban, All
> Thanks for the help. :)
> Actually I did check smbclient 2.2.2 on command line on Solaris 5.8.The 
> corrupted output it gives is visually same as the corrupted output 
> obtained through the input stream of the java Process and thereafter 
> printed to log file. Dot to dot they match!
> The machine which contains files with names in Japanese is a Windows 
> 2000 machine. I tried accessing the files through Sun's Java FTP API. In 
> this case, if I use an InputStreamReader with Shift-JIS as encoding for 
> the stream being read in, I get the file names correctly listed. So 
> there is not problem atleast in the Java classes I am using to handle 
> the Japanese characters.
> InputStreamReader created for a certain encoding will read the stream 
> and give out a stream of correct characters. I have even tried reading 
> all the bytes into a ByteArrayOutputStream and creating a String with 
> all the encoding types. It still does not work. Funnily, none of the 
> characters in the String so created is above 255! They are all ASCII! 
> Some should be Japanese!
	How do you know it's not working but the display you're on can't handle
	the output? Try running a UTF-8 XTerm like:

	$ xterm -u8

	Then run your program in a UTF-8 locale like:

	xterm$ LANG=en_US.utf8 java MyProg blah blah blah

	Does the "coruption" change? Be carefull NOT to do stuff like:

	char[] d = (new String( b, 0, b ), "UTF8" )).toCharArray();

	This just doesn't work and I don't know why exactly. You have to do more like:

	BufferedReader in = new BufferedReader(
	                          new InputStreamReader( new FileInputStream( "testfile" )));
	char[] d = new char[4096]; d, 0, 4096 )

	...etc. How they know it's UTF-8 is beyond me but this is how it works.


> My line of thinking is, they byte stream which is being returned by 
> smbclient through Process.getInpuStream() is such that all the Java API 
> are interpreting them as ASCII inspite of a proper character encoding 
> being set. Can there be a problem with the bytes smbclient returns for 
> the character stream it gets from Windows 2000 as file listing?
> I am looking into jCIFS too. But I'd like to have an answer to current 
> dilemma too. :) Never say die! :)
	I'm in the process of fixing jCIFS as we speak. I'm testing it right now actually.


> Thanks again for the help. Who says Open Source is without good support! :)
	Fast too.

More information about the smb-clients mailing list