Skip to main content



      Home
Home » Newcomers » Newcomers » Character Encoding Java Win 7 Japanese
Character Encoding Java Win 7 Japanese [message #782033] Sun, 22 January 2012 21:06 Go to next message
Eclipse UserFriend
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: Sun, 22 January 2012 21:18] by Moderator

Re: Character Encoding Java Win 7 Japanese [message #782127 is a reply to message #782033] Mon, 23 January 2012 03:16 Go to previous messageGo to next message
Eclipse UserFriend
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 06:12 Go to previous messageGo to next message
Eclipse UserFriend
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 09:28 Go to previous message
Eclipse UserFriend
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 09:29] by 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: Sun Jul 13 20:26:21 EDT 2025

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

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

Back to the top