Issue: Working with UTF-16 Encoded Files in Linux

Problem:

When trying to process a binary/encoded file (IPG_APP1_DISK_old.log), tools like grep, strings, and less don't return expected results. The file is identified as UTF-16 encoding (little-endian) with CRLF line terminators, causing issues when searching or processing with typical text-processing tools.

Solution:

To resolve the issue, the file needs to be converted from UTF-16 to UTF-8 encoding.

Steps to Fix:

  1. Convert the File from UTF-16 to UTF-8: Use the iconv tool to convert the file encoding to UTF-8:
   iconv -f UTF-16 -t UTF-8 IPG_APP1_DISK_old.log > IPG_APP1_DISK_old_utf8.log

The converted file will be saved as IPG_APP1_DISK_old_utf8.log.

file IPG_APP1_DISK_old_utf8.log

Ensure it now shows UTF-8.

Search the Converted File: Now that the file is in UTF-8 format, use standard text-processing tools like grep to search for specific terms (e.g., "hms"):

grep "hms" IPG_APP1_DISK_old_utf8.log
strings IPG_APP1_DISK_old_utf8.log | grep "hms"

Written by A.M. Rinas