Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Console Encoding Setting
Console Encoding Setting [message #890179] Thu, 21 June 2012 11:38 Go to next message
Missing name Mising name is currently offline Missing name Mising nameFriend
Messages: 43
Registered: July 2011
Member
There are two settings which can affect console encoding.
One must set the same encoding to prevent garble.

I'm not sure this is really a bug, so please let me hear your comments.
Rolling Eyes
---

Configuration A. ( eclipse default encoding )

eclipse.ini
-Dfile.encoding=

(If there is no Dfile.encoding~ statement in eclipse.ini, Platform default encoding is used.)

---

Configuration B. ( Run Configuration )

Run -> Run Configuration -> Common -> Encoding

---

If A. and B. have different settings, it seems Console Input( byte array ) is doubly encoded.

--SETTING--
A. MS932
B. EUC-JP

--SRC--
public class EncodingCheck {
	public static void main(String[] args) throws IOException {
		BufferedInputStream in = new BufferedInputStream(System.in);

		byte[] bytes = new byte[10];
		bytes = Arrays.copyOf(bytes, in.read(bytes));

		for (byte b : bytes) {
			System.out.printf("%02x ", b);
		}
	}
}


--INPUT--


--OUTPUT--
8e a4 8e a2 0d 0a

---What happened?---

a4 a2 : あ (EUC-JP)
8e : control character
0d 0a : CR LF ( line break )

Conrtorl character (8e) is unnecessary, so this "INPUT" is garbled.

--

STEP 1. read あ as [EUC-JP]
a4 a2

STEP 2. read a4 a2 as [MS932]
"、「 " (String)

STEP 3. read "、「 " as [EUC-JP]
8e a4 8e a2 ( CONTROL CHARACTER INSERTED HERE! )

-----

B.(Run Configuration) not only affects console encoding, but also sets the Running Program's default encoding ( "file.encoding" property ).

So I think "A.(eclipse default encoding) affects Console Input" might be a bug ( STEP 2. makes bug ).
Re: Console Encoding Setting [message #890396 is a reply to message #890179] Fri, 22 June 2012 08:12 Go to previous messageGo to next message
Dani Megert is currently offline Dani MegertFriend
Messages: 3802
Registered: July 2009
Senior Member
On 21.06.2012 13:38, Watabe Kichi wrote:
> There are two settings which can affect console encoding.
> One must set the same encoding to prevent garble.
>
> I'm not sure this is really a bug, so please let me hear your comments.
See https://bugs.eclipse.org/382257

Dani
> :roll: ---
>
> Configuration A. ( eclipse default encoding )
>
> eclipse.ini
> -Dfile.encoding=
>
> (If there is no Dfile.encoding~ statement in eclipse.ini, Platform
> default encoding is used.)
>
> ---
>
> Configuration B. ( Run Configuration )
>
> Run -> Run Configuration -> Common -> Encoding
>
> ---
>
> If A. and B. have different settings, it seems Console Input( byte
> array ) is doubly encoded.
>
> --SETTING--
> A. MS932
> B. EUC-JP
>
> --SRC--
>
> public class EncodingCheck {
> public static void main(String[] args) throws IOException {
> BufferedInputStream in = new BufferedInputStream(System.in);
>
> byte[] bytes = new byte[10];
> bytes = Arrays.copyOf(bytes, in.read(bytes));
>
> for (byte b : bytes) {
> System.out.printf("%02x ", b);
> }
> }
> }
>
>
> --INPUT--
> あ
>
> --OUTPUT--
> 8e a4 8e a2 0d 0a
>
> ---What happened?---
>
> a4 a2 : あ (EUC-JP)
> 8e : control character
> 0d 0a : CR LF ( line break )
>
> Conrtorl character (8e) is unnecessary, so this "INPUT" is garbled.
>
> --
>
> STEP 1. read あ as [EUC-JP]
> a4 a2
>
> STEP 2. read a4 a2 as [MS932]
> "、「 " (String)
>
> STEP 3. read "、「 " as [EUC-JP]
> 8e a4 8e a2 ( CONTROL CHARACTER INSERTED HERE! )
>
> -----
>
> B.(Run Configuration) not only affects console encoding, but also sets
> the Running Program's default encoding ( "file.encoding" property ).
>
> So I think "A.(eclipse default encoding) affects Console Input" might
> be a bug ( STEP 2. makes bug ).
Re: Console Encoding Setting [message #890769 is a reply to message #890396] Sat, 23 June 2012 02:16 Go to previous message
Missing name Mising name is currently offline Missing name Mising nameFriend
Messages: 43
Registered: July 2011
Member
Thank you for the information.

I haven't tested yet, but I hope the fix will be applied soon.
Previous Topic:Can't see custom warnings in eclipse
Next Topic:ASTNode type and variable bindings
Goto Forum:
  


Current Time: Fri Apr 26 15:54:54 GMT 2024

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

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

Back to the top