Skip to content

Commit

Permalink
use UTF-8 as default encoding in the Terminal (#1020)
Browse files Browse the repository at this point in the history
the rest of Eclipse now uses UTF-8 as default encoding.

The tm.terminal code reverts to null when the encoding
begins with "Default" and this leads to UTF-8 being
selected from Charset.defaultEncoding instead of ISO-8859
when the displayed default value is selected.

Co-authored-by: Philipp SALZGEBER <[email protected]>
  • Loading branch information
astrograph and Philipp SALZGEBER authored Jan 17, 2025
1 parent 8d06425 commit 3439e0e
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 11 deletions.
9 changes: 9 additions & 0 deletions NewAndNoteworthy/CDT-12.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ The View Performance preference page, which is CDT specific, has been relocated
This only affects where in the Preferences tree the page is located, the preferences and key names have not changed.
In addition, this page is always visible.

# Terminal

## Default encoding for terminal is now UTF-8

For a [while](https://eclipse.dev/eclipse/news/4.24/platform.html#explicit-encoding-workspaces), the default encoding in Eclipse has been UTF-8.
Starting in CDT 12, the Terminal will now default to UTF-8.

<p align="center"><img src="images/CDT-12.0-default-terminal-encoding.png"></p>

# API Changes, current and planned

## Breaking API changes
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ protected void fillSettingsForHost(String host) {
if (encoding == null || "null".equals(encoding)) { //$NON-NLS-1$
String defaultEncoding = getSelectionEncoding();
encoding = defaultEncoding != null && !"".equals(defaultEncoding.trim()) ? defaultEncoding.trim() //$NON-NLS-1$
: "ISO-8859-1"; //$NON-NLS-1$
: "UTF-8"; //$NON-NLS-1$
}
setEncoding(encoding);
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
###############################################################################
# Copyright (c) 2018, 2024 Contributors to the Eclipse Foundation
# Copyright (c) 2018, 2025 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
Expand All @@ -24,7 +24,7 @@ blurb=TM Terminal Control\n\
Version: {featureVersion}\n\
Build id: {0}\n\
\n\
Copyright (c) 2018, 2024 Contributors to the Eclipse Foundation
Copyright (c) 2018, 2025 Contributors to the Eclipse Foundation
\n\
See the NOTICE file(s) distributed with this work for additional\n\
information regarding copyright ownership.\n\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1210,7 +1210,7 @@ private void processAnsiCommand_n() {
}

try {
terminal.getOutputStream().write(reply.getBytes("ISO-8859-1")); //$NON-NLS-1$
terminal.getOutputStream().write(reply.getBytes("UTF-8")); //$NON-NLS-1$
terminal.getOutputStream().flush();
} catch (IOException ex) {
Logger.log("Caught IOException!"); //$NON-NLS-1$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public void setCharset(Charset charset) {

@Override
public String getEncoding() {
return "ISO-8859-1"; //$NON-NLS-1$
return "UTF-8"; //$NON-NLS-1$
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public void setCharset(Charset charset) {

@Override
public String getEncoding() {
return "ISO-8859-1"; //$NON-NLS-1$
return "UTF-8"; //$NON-NLS-1$
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ protected void fillEncodingCombo() {
List<String> encodings = new ArrayList<>();

// Default encoding
encodings.add("Default (ISO-8859-1)"); //$NON-NLS-1$
encodings.add("Default (UTF-8)"); //$NON-NLS-1$

// The currently selected IDE encoding from the preferences
String ideEncoding = getResourceEncoding();
Expand Down Expand Up @@ -612,7 +612,7 @@ protected void setEncoding(String encoding) {
Assert.isNotNull(encoding);

if (encodingCombo != null && !encodingCombo.isDisposed()) {
int index = encodingCombo.indexOf("ISO-8859-1".equals(encoding) ? "Default (ISO-8859-1)" : encoding); //$NON-NLS-1$ //$NON-NLS-2$
int index = encodingCombo.indexOf("UTF-8".equals(encoding) ? "Default (UTF-8)" : encoding); //$NON-NLS-1$ //$NON-NLS-2$
if (index != -1)
encodingCombo.select(index);
else {
Expand Down Expand Up @@ -642,7 +642,7 @@ protected String getEncoding() {
protected boolean isEncodingValid() {
try {
String encoding = getEncoding();
return Charset.isSupported(encoding != null ? encoding : "ISO-8859-1"); //$NON-NLS-1$
return Charset.isSupported(encoding != null ? encoding : "UTF-8"); //$NON-NLS-1$
} catch (IllegalCharsetNameException e) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -833,8 +833,8 @@ public final void updateStatusLine() {
buffer.append(" - "); //$NON-NLS-1$

String encoding = terminal.getEncoding();
if (encoding == null || "ISO-8859-1".equals(encoding)) { //$NON-NLS-1$
encoding = "Default (ISO-8859-1)"; //$NON-NLS-1$
if (encoding == null || "UTF-8".equals(encoding)) { //$NON-NLS-1$
encoding = "Default (UTF-8)"; //$NON-NLS-1$
}
buffer.append(NLS.bind(Messages.TabFolderManager_encoding, encoding));

Expand Down

0 comments on commit 3439e0e

Please sign in to comment.