smbclient/solaris/smbclient

Allen, Michael B (RSCH) Michael_B_Allen at ml.com
Fri May 3 05:12:55 GMT 2002


> -----Original Message-----
> From:	Allen, Michael B (RSCH) 
> 
> 	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:
> 
		Oops! I mean the other way around. You DO want to do like the below and NOT like the
		example after it. In other words you do not want to use InputStreamReader. Actually I just found
		out that the "UTF-8" used by Java and DataInput is modified!

		Mike


> 	char[] d = (new String( b, 0, in.read( 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]; 
> 	in.read( d, 0, 4096 )
> 
> 	...etc. How they know it's UTF-8 is beyond me but this is how it works.
> 





More information about the smb-clients mailing list