欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

Java CMD命令行输出中文乱码问题

程序员文章站 2022-07-10 18:49:46
1、使用aapt命令显示apk信息,发现中文的应用名显示为一串乱码C:\Users\Administrator>aapt d badging C:\Users\Administrator\Desktop\zhztttb4_739_1_3250_3384_64662_ad.apkpackage: name='com.zwzt.sszt4' versionCode='1596518241' versionName='1.0.8.1' platformBuildVersionName='6.0-2438...

1、使用aapt命令显示apk信息,发现中文的应用名显示为一串乱码

C:\Users\Administrator>aapt d badging C:\Users\Administrator\Desktop\zhztttb4_739_1_3250_3384_64662_ad.apk
package: name='com.zwzt.sszt4' versionCode='1596518241' versionName='1.0.8.1' platformBuildVersionName='6.0-2438415' compileSdkVersion='23' compileSdkVersionCodename='6.0-2438415'
install-location:'auto'
sdkVersion:'17'
targetSdkVersion:'22'

uses-permission: name='android.permission.ACCESS_FINE_LOCATION'
uses-permission: name='android.permission.ACCESS_COARSE_LOCATION'
uses-permission: name='android.permission.WRITE_SETTINGS'
uses-permission: name='android.permission.BLUETOOTH'
uses-permission: name='android.permission.BLUETOOTH_ADMIN'
uses-permission: name='android.permission.ACCESS_FINE_LOCATION'
uses-permission: name='android.permission.ACCESS_COARSE_LOCATION'
uses-permission: name='android.permission.INTERNET'
uses-permission: name='android.permission.READ_PHONE_STATE'
uses-permission: name='android.permission.ACCESS_NETWORK_STATE'
uses-permission: name='android.permission.CHANGE_WIFI_STATE'
application-label:'??????????€?'
application-label-af:'??????????€?'
application-label-am:'??????????€?'
application-label-ar:'??????????€?'
application-label-az:'??????????€?'
application-label-be:'??????????€?'
application-label-bg:'??????????€?'
application-label-bn:'??????????€?'
application-label-bs:'??????????€?'
application-label-vi:'??????????€?'
application-label-zh-CN:'??????????€?'
application-label-zh-HK:'??????????€?'
application-label-zh-TW:'??????????€?'
application-label-zu:'??????????€?'

2、出现乱码原因在于,cmd命令行默认编码是GBK,而aapt默认编码是UTF-8,鼠标放在命令行顶部,右键 - 属性
Java CMD命令行输出中文乱码问题
3、咱们可以在命令行输入CHCP 65001,回车,将当前窗口改为UTF-8编码,咱们再重新运行一下上述命令,发现aapt输出到cmd的中文正常显示出来了

Active code page: 65001

C:\Users\Administrator>aapt d badging C:\Users\Administrator\Desktop\zhztttb4_739_1_3250_3384_64662_ad.apk
package: name='com.zwzt.sszt4' versionCode='1596518241' versionName='1.0.8.1' platformBuildVersionName='6.0-2438415' compileSdkVersion='23' compileSdkVersionCodename='6.0-2438415'
install-location:'auto'
sdkVersion:'17'
targetSdkVersion:'22'
uses-permission: name='android.permission.INTERNET'
uses-permission: name='android.permission.VIBRATE'
uses-permission: name='android.permission.GET_TASKS'
uses-permission: name='android.permission.SYSTEM_ALERT_WINDOW'
uses-permission: name='getui.permission.GetuiService.com.ztyh.mg'
uses-permission: name='com.coloros.mcs.permission.RECIEVE_MCS_MESSAGE'
uses-permission: name='android.permission.DOWNLOAD_WITHOUT_NOTIFICATION'
uses-permission: name='android.permission.REQUEST_INSTALL_PACKAGES'
uses-permission: name='getui.permission.GetuiService.com.zwzt.sszt4'
uses-permission: name='android.permission.READ_EXTERNAL_STORAGE'
application-label:'纵横征途'
application-label-af:'纵横征途'
application-label-ur:'纵横征途'
application-label-uz:'纵横征途'
application-label-vi:'纵横征途'
application-label-zh-CN:'纵横征途'
application-label-zh-HK:'纵横征途'
application-label-zh-TW:'纵横征途'
application-label-zu:'纵横征途'

4、上述方法仅仅是可以解决cmd中文乱码问题而已,要是java -jar执行输出的是UTF-8编码的中文,按照上述方案修改,不仅仅依然还是乱码,而且缩成一坨了,有些没显示出来

C:\Users\Administrator>java -jar C:\Users\Administrator\Desktop\apkparser\game.jar

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>  apkϢ <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<



װС240.8M
װMD512a6937661c57646f38ff8302b65797b
װ޸ʱ䣺2020-08-21 14:27:45

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>   apkȨϢ  <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
uses-permission: name='com.asus.msa.SupplementaryDID.ACCESS'
uses-permission: name='android.permission.INTERNET'
uses-permission: name='android.permission.ACCESS_NETWORK_STATE'
uses-permission: name='android.permission.WRITE_EXTERNAL_STORAGE'
uses-permission: name='ANDROID.PERMISSION.READ_EXTERNAL_STORAGE'
uses-permission: name='android.permission.READ_PHONE_STATE'
uses-permission: name='android.permission.ACCESS_WIFI_STATE'
uses-permission: name='android.permission.RECORD_AUDIO'
uses-permission: name='android.permission.VIBRATE'
uses-permission: name='android.permission.GET_TASKS'
uses-permission: name='com.android.launcher.permission.INSTALL_SHORTCUT'
uses-permission: name='android.permission.SYSTEM_OVERLAY_WINDOW'

5、对于java -jar执行输出的中文乱码问题,需要增加一个系统选项设置-Dfile.encoding=UTF-8即可


C:\Users\Administrator>java -Dfile.encoding=UTF-8 -jar C:\Users\Administrator\Desktop\apkparser\game.jar


>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>  apk基本信息 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
包名:com.sswl.zttx3
版本号:1597232915
版本名:1.0.8.2
安装位置:auto
最小兼容版本:17
最大兼容版本:22
应用名:岁月征途
icon路径:res/drawable-mdpi/app_icon.png
启动的主Activity:com.shenghe.zt.FirstActivity
兼容手机架构:armeabi-v7a
安装包大小:240.8M
安装包MD5:12a6937661c57646f38ff8302b65797b
安装包最新修改时间:2020-08-21 14:27:45

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>   apk权限信息  <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
uses-permission: name='com.asus.msa.SupplementaryDID.ACCESS'
uses-permission: name='android.permission.INTERNET'
uses-permission: name='android.permission.ACCESS_NETWORK_STATE'
uses-permission: name='android.permission.WRITE_EXTERNAL_STORAGE'
uses-permission: name='ANDROID.PERMISSION.READ_EXTERNAL_STORAGE'
uses-permission: name='android.permission.READ_PHONE_STATE'
uses-permission: name='android.permission.ACCESS_WIFI_STATE'
uses-permission: name='android.permission.RECORD_AUDIO'
uses-permission: name='android.permission.VIBRATE'
uses-permission: name='android.permission.GET_TASKS'
uses-permission: name='com.android.launcher.permission.INSTALL_SHORTCUT'

【备注】
假如是在Window PowerShell中执行 java -Dfile.encoding=GBK,会提示错误:错误: 找不到或无法加载主类 .encoding=GBK,需要换回原始的命令行工具cmd

本文地址:https://blog.csdn.net/qq_43278826/article/details/108872625

相关标签: java cmd