[Linux] How to deal with garbled characters when viewing files

A memorandum on how to browse files without garbled characters

environment

procedure

1. Check the character code of the target file

(1) Execute the following command

nkf --guess filename
nkf --guess hoge.php

2. Open the file with the corresponding character code

(1) Execute the following command

cat file name|nkf character code specification (input related)
cat hoge.php | nkf -E
option Character code
-J ISO-2022-JP
-E EUC-JP
-S Shift-JIS
-W,-W8 UTF-8
-W16 UTF-16 (little endian)
-W16B UTF-16 (Big Endian)

At the end

Recently, I often encounter problems that are garbled and unreadable, so I made it available immediately.

reference

Recommended Posts

[Linux] How to deal with garbled characters when viewing files
How to deal with errors when hitting pip ②
How to deal with SessionNotCreatedException when using Selenium
How to deal with garbled characters in json of Django REST Framework
How to handle static files when deploying to production with Django
How to deal with imbalanced data
How to deal with imbalanced data
How to deal with DistributionNotFound errors
How to deal with the problem that Japanese characters are garbled when outputting logs using JSON log formatter
How to deal with UnicodeDecodeError when executing google image download
How to deal with errors when installing whitenoise and deploying to Heroku
How to deal with errors when installing Python and pip with choco
[Linux] How to subdivide files and folders
How to deal with enum compatibility errors
How to power off Linux with Ultra96-V2
[Python] How to deal with module errors
How to find large files on Linux
How to get started with laravel (Linux)
[HOW TO] Easy way to debug when generating PDF files with PHP etc.
How to deal with OAuth2 error when using Google APIs from Python
How to deal with SSL error when connecting to S3 with boto of Python
[AWS] How to deal with WordPress "An error occurred when cropping an image."
How to deal with memory leaks in matplotlib.pyplot
can't pickle annoy. How to deal with Annoy objects
How to deal with module'tensorflow' has no attribute'〇〇'
[EC2] Prevent garbled characters when capturing with selenium
[Python] How to handle Japanese characters with openCV
How to make Linux compatible with Japanese keyboard
How to deal with Django's Template Does Not Exist
How to deal with pyenv initialization failure in fish 3.1.0
How to load files in Google Drive with Google Colaboratory
How to access with cache when reading_json in pandas
How to eliminate garbled characters in matplotlib output image
[Python] How to deal with pandas read_html read error
How to deal with Executing transaction: failed in Anaconda
How to deal with "Type Error: No matching signature found" error when using pandas fillna
How to not load images when using PhantomJS with Selenium
[Cyberduck] How to exchange files on Linux (CentOS7) started by VirtualBox with mac using GUI
How to update with SQLAlchemy?
What I was addicted to when dealing with huge files in a Linux 32bit environment
How to resolve CSRF Protection when using AngularJS with Django
How to upload files to Cloud Storage with Firebase's python SDK
How to cast with Theano
[AWS] How to deal with "Invalid codepoint" error in CloudSearch
A story about how to deal with the CORS problem
How to Alter with SQLAlchemy?
For beginners, how to deal with common errors in keras
How to separate strings with','
How to deal with the terminal getting into the pipenv environment without permission when using pipenv with vscode
How to RDP with Fedora31
2 ways to deal with SessionNotCreatedException
How to Delete with SQLAlchemy?
How to output additional information when logging with python's logging module
How to deal with the problem that the current directory moves when Python is executed from Atom
How to deal with the error "Failed to load module" canberra-gtk-module "that appears when you run OpenCV
How to display a specified column of files in Linux (awk)
How to deal with python installation error in pyenv (BUILD FAILED)
How to deal with "You have multiple authentication backends configured ..." (Django)
How to import CSV and TSV files into SQLite with Python
How to install pandas on EC2 (How to deal with MemoryError and PermissionError)
[Web development with Python] Measures against garbled characters when outputting html