• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Rob Spoor
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Holloway
  • Piet Souris
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Himai Minh

Characters and character set in console apps

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am learning about keyboard input using the Scanner class, then printing it to the terminal / console window in Netbeans.  I notice that some special characters entered get changed when they are output again. Something to do with wrong character set How to fix this please?
 
Marshal
Posts: 73760
332
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is this the NetBeans console or a Windows® command prompt? Are you putting the input in the same place?
This page from Microsoft says,

Console – built in a pre-Unicode dawn

and explains that it doesn't support UTF‑8 but they are working at it. Don't know about NetBeans. I think (not sure) that Java® by default has output in the UTF‑16 encoding.
 
Antonio Moretti
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:Is this the NetBeans console or a Windows® command prompt? Are you putting the input in the same place?
This page from Microsoft says,

Console – built in a pre-Unicode dawn

and explains that it doesn't support UTF‑8 but they are working at it. Don't know about NetBeans. I think (not sure) that Java® by default has output in the UTF‑16 encoding.



I noticed it both in console and Netbeans. However you have now given me a clue about how to solve it in Netbeans. Thank you.
 
Bartender
Posts: 1059
33
Eclipse IDE Postgres Database C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For those using Windows 10 (or 11?) "Windows Terminal" is an extremely modern, open-source project which is a Windows Store download and provides almost everything you might want in a terminal except there are problems with the case of inputting data in UTF-8 (part they are still working on).

I try never to use the legacy Windows Console for too many reasons to list here, it is stuck deep in the past.

The same gaggle of devs actually work on both, but the Windows Console version has 40 years of Backwards Compatibility Nightmares to contend with, the Windows Terminal code gets to actually live in this century.

Your mileage probably won't vary much.
 
Antonio Moretti
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jesse Silverman wrote:For those using Windows 10 (or 11?) "Windows Terminal" is an extremely modern, open-source project which is a Windows Store download and provides almost everything you might want in a terminal except there are problems with the case of inputting data in UTF-8 (part they are still working on).

I try never to use the legacy Windows Console for too many reasons to list here, it is stuck deep in the past.

The same gaggle of devs actually work on both, but the Windows Console version has 40 years of Backwards Compatibility Nightmares to contend with, the Windows Terminal code gets to actually live in this century.

Your mileage probably won't vary much.



Why would you want to use a Windows Store app instead of Windows Powershell?
 
Jesse Silverman
Bartender
Posts: 1059
33
Eclipse IDE Postgres Database C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Antonio Moretti wrote:
Why would you want to use a Windows Store app instead of Windows Powershell?



That is a false choice.
Let me explain.
PowerShell is just a language and libraries, it doesn't "have" a set GUI.

It can be hosted for I/O purposes in any of countless choices of terminal application.

You can buy one, write one, build an open source one from source, etc. etc.

Windows Terminal can have cmd (yuck), PowerShell, JShell, bash, zsh, fish, etc. etc. etc. running in it.

So the choice of the terminal application is (almost completely but not quite) independent of your choice of shell or shell-like application.

Why would one want to be using Windows Terminal rather than the Legacy Console to run any of these, when I have already revealed the same guys are working on both?

Because Legacy Console needs to run billions of things that were written using accidental, pathological misfeatures that happened to be exposed in Console for 40 years, all of them.

It needs to preserve weird confusing behaviors from long before any of the people working on it were born.

The same developers in the Windows Terminal side aren't forced to pretend it is the 80's, they can do things the "right way" because it isn't guaranteed to behave identically to a Console from 1983.

There are a ton of commercial and open-source terminal options on Windows that are all a better choice than legacy Console.

Windows Terminal has a lot of effort behind it, and is arguably more standard than most of those.

The Windows Terminal team also has re-written lots of API's so you can choose to write your own terminal if you really want to.

I for sure don't have time to do that, it is a lot of work.

In a Corporate Environment, which I hope to return to quite soon, there are often many restrictions placed on your dependencies and toolchains compared to what you might decide to choose at home or consulting for small places that delegate all such decisions to you.  More than I ever realized, like, a LOT of restrictions.  Maybe waiting three weeks for approval for something you just casually want to use that day.

In such environments, knowing how to make use of pre-approved, already available options greatly increases your productivity.
 
Jesse Silverman
Bartender
Posts: 1059
33
Eclipse IDE Postgres Database C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For completeness, at the moment I type jshell I am normally in Windows Terminal at that moment, running PowerShell, looking like this:
PowerShell 7.1.4
Copyright (c) Microsoft Corporation.

https://aka.ms/powershell
Type 'help' to get help.

PS F:\Labs> Get-Host

Name             : ConsoleHost
Version          : 7.1.4
InstanceId       : f1c6933e-e966-44be-b7b5-bee5e37b118d
UI               : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture   : en-US
CurrentUICulture : en-US
PrivateData      : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
DebuggerEnabled  : True
IsRunspacePushed : False
Runspace         : System.Management.Automation.Runspaces.LocalRunspace


PS F:\Labs> help get-host

NAME
   Get-Host

SYNOPSIS
   Gets an object that represents the current host program.


This doesn't matter, except where it does.  It has come up a few times in some threads when discussing details of dealing with UTF-16 or UTF-8 in Java Console applications.
 
Yes, my master! Here is the tiny ad you asked for:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic