Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Character Encoding Java Win 7 Japanese
Character Encoding Java Win 7 Japanese [message #782033] Mon, 23 January 2012 02:06 Go to next message
hank mobley is currently offline hank mobleyFriend
Messages: 3
Registered: January 2012
Junior Member
When I query my Win 7 Japanese system with this:


import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Mixer;


public class TestClass {
	public static void main(String[] args){
		
		Mixer.Info[] mixers = AudioSystem.getMixerInfo(); 	
		System.out.println(mixers[0].toString());
	}

}


The output becomes:

????? ???? ?????, version Unknown Version


I have tried the various encoding options in Eclipse. I have installed the Eclipse Japanese language pack. I have also scoured the web for answers - for days! Some answers involved deleting config files in the JRE folder, others were specific to Netbeans or another IDE. Some where Linux/Unix and others Mac. Some were in Japanese, some in English and some Russian. None of them were specific to Eclipse on Win 7 and none of them worked for me.

Thank you in advance for any help.

[Updated on: Mon, 23 January 2012 02:18]

Report message to a moderator

Re: Character Encoding Java Win 7 Japanese [message #782127 is a reply to message #782033] Mon, 23 January 2012 08:16 Go to previous messageGo to next message
Toshihiro Izumi is currently offline Toshihiro IzumiFriend
Messages: 360
Registered: July 2009
Location: Japan
Senior Member
No relation to Eclipse.

AudioSystem.getMixerInfo() returns raw data.(not Java string) You need to decode it.
try {
	byte[] bytes = mixers[0].getName().getBytes("iso-8859-1");
	String name = new String(bytes, "ms932");
	System.out.println(name);
} catch (UnsupportedEncodingException e) {
}

Re: Character Encoding Java Win 7 Japanese [message #782219 is a reply to message #782127] Mon, 23 January 2012 11:12 Go to previous messageGo to next message
hank mobley is currently offline hank mobleyFriend
Messages: 3
Registered: January 2012
Junior Member
Thank you Mr. Izumi for you help. I have adopted your code and it now appears:

import java.io.UnsupportedEncodingException;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Mixer;


public class TestClass {
	public static void main(String[] args){
		Mixer.Info[] mixers = AudioSystem.getMixerInfo();
		try{
			byte[] bytes = mixers[0].getName().getBytes("iso-8859-1");
			String name = new String(bytes, "ms932");
			System.out.println(name);
			}catch (UnsupportedEncodingException e){
				
			}
		}
	}


Unfortunately my output in the console is still:

????? ???? ?????


Thank you for pointing out string vs raw data issue. I'm a complete beginner and so may need a bit of hand-holding.

I will continue to pursue this issue now with the added insight you have provided.

If you have any more suggestions please let me know.

Thank you!
Re: Character Encoding Java Win 7 Japanese [message #782319 is a reply to message #782219] Mon, 23 January 2012 14:28 Go to previous message
hank mobley is currently offline hank mobleyFriend
Messages: 3
Registered: January 2012
Junior Member
I put together an install of Ubuntu + OpenJDK and compiled my original code:

public class TestClass {
	public static void main(String[] args){
		
		Mixer.Info[] mixers = AudioSystem.getMixerInfo(); 	
		System.out.println(mixers[0].toString());
	}

}


And it worked:

PulseAudio Mixer, version 0.02


I still have no clue what's happening between Windows and Java. It's now quite obviously not an Eclipse issue. I still would appreciate any imput.

[Updated on: Mon, 23 January 2012 14:29]

Report message to a moderator

Previous Topic:Automatic build using buildbot and subversion
Next Topic:Changes to eclipse.ini in case of exit code=13
Goto Forum:
  


Current Time: Thu Mar 28 13:03:32 GMT 2024

Powered by FUDForum. Page generated in 0.05404 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top