Windows Command Results Are garbled in Git Bash

Asked 2 years ago, Updated 2 years ago, 89 views

When you type Windows standard commands on Git Bash (MinGW), the results are displayed in a literal format.

route/? for example

Example typing route/?

Locale settings in Terminal Options do not work.Is there a way to get rid of garbled characters?

Terminal Options>Text>Locale(UTF8)

mingw git-bash

2022-09-30 11:30

2 Answers

In fact, if you select SJIS in the locale above, it will be resolved, but this time you will not be able to display the Japanese file name on ls.s.This is because Bash locale is UTF8.
So for standard Windows commands, wouldn't it be best practice to have the code page Unicode and display it in English?

If there is a better way, please reply.


2022-09-30 11:30

If I set SJIS to LANG, I could also display the Japanese file name.

    In
  • Options, configure Locale and Character set as follows:

    • Locale:Ja_JP
    • Character set:SJIS
  • Set the environment variable LANG in terminal (mintty) as follows:

In Options, configure Locale and Character set as follows:

  • Locale:Ja_JP
  • Character set:SJIS

Set the LANG environment variable on the terminal (mintty) as follows:

LANG=ja_JP.sjis

route/? does not corrupt Japanese.

$route/?

Manipulate the network routing table.

ROUTE [-f][-p][-4 | -6] command [destination]
      MASK netmask gateway METRIC metric IF interface

  Clearing all gateway entries in the -f routing table
               Yes, if this option is used with the command, execute the command
               The table is cleared before you do .

I was able to display a file with Chinese characters.

$ls-l/c/junc/Chinese name file.txt
-rw-r--r--1XXXXXX00 May 901:59/c/junc/Chinese name file.txt

XXX XXXX is hidden.


2022-09-30 11:30

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.