Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Incorrect console encoding under Windows 11(Console encoding is windows-1252 despite default encoding set to UTF-8)
Incorrect console encoding under Windows 11 [message #1853044] Wed, 15 June 2022 15:44
Ulrich Schmidt is currently offline Ulrich SchmidtFriend
Messages: 1
Registered: June 2022
Junior Member
Hello,

when using JDK-18 from Oracle with "Text file encoding" set to default (UTF-8) the following code

import java.nio.charset.*;

public class ABC {
	public static void main(String[] args) {
		System.out.println(Charset.defaultCharset());
		System.out.println(System.console());
		System.out.println(System.out.charset());
		System.out.println("äöü߀");
	}
}


generates the following output


UTF-8
null
windows-1252
���߀


which is clearly incorrect. The documentation of System.out specifies

Quote:

The encoding used in the conversion from characters to bytes is equivalent to Console.charset() if the Console exists, Charset.defaultCharset() otherwise.


but as the example shows the default character set is not used for console encoding.

Is this a bug? If so, is there a work-around?
Previous Topic:Eclipse release 2022-06 dependency break
Next Topic:A Newbie's ??
Goto Forum:
  


Current Time: Thu Apr 25 21:16:06 GMT 2024

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

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

Back to the top