Linux


14
Aug 10

Nautilus script for converting text file encoding to UTF-8 in Ubuntu

Here is a Nautilus script that detects the original character encoding of selected text files and automatically converts them to your local native encoding (which should be UTF-8 in Ubuntu).

To run the script, you need to place it in the ~/.gnome2/nautilus-scripts directory and give it execute permissions.

You also need to install the following packages:
enca
libnotify-bin

#!/bin/sh
#
# Filename: Enconv Tool
# Date: 2008/02/02 15:10:34
# Licence: GNU GPL
# Dependency: enca, libnotify-bin
# Author: Jonathan Lumb 

# Do the conversion
enconv "$@"

# Display success / error message
if [ "$?"-ne 0]
then
notify-send -i /usr/share/icons/Humanity/actions/48/gtk-cancel.svg "Error" "Files were not converted"
exit 1
else
notify-send -i /usr/share/icons/Humanity/actions/48/document-export.svg "Success" "Files were successfully converted"
fi
exit 0


14
Aug 10

Convert BIG5 or GB18030 (Chinese Character Encoding) to UTF-8 in Ubuntu

I watch a lot of Chinese films in my spare time and often download Chinese subtitles to facilitate viewing. The problem is that most text-based subtitle files provided on the internet are created in Windows and encoded in either GB18030 (Simplified Chinese) or BIG5 (Traditional Chinese) character sets. These files won’t display properly on Ubuntu and must be converted to UTF-8 encoding if they are to be useful.

I found that there are (at least) three ways of converting files using these character sets on Ubuntu – using the iconv, the recode and the enconv utilities. The iconv utility preserves the original text file and creates a new output file, the recode utility overwrites the original text file with the new encoding whilst the econv utility tops them all off by detecting the encoding of the source file automatically and then converting it to your local native encoding (UTF-8 on Ubuntu).

Below I will demonstrate how each of these utilities can be used:

The iconv method
The iconv utility should be installed by default on Ubuntu

In a terminal, browse to the directory where the target files are located and use either of the commands below, the former for converting from GB18030 to UTF-8 and the latter from BIG6 to UTF-8.

iconv -f gb18030 -t utf8 src_filename -o output_filename
iconv -f big5 -t utf8 src_filename -o output_filename

The recode method

You may need to install the recode package on your system before preceding:

sudo apt-get install recode

In a terminal, browse to the directory where the target files are located and use either of the commands below, the former for converting from GB18030 to UTF-8 and the latter from BIG6 to UTF-8.

recode GB18030 src_filename
recode BIG5 src_filename

The enconv method

You will probably need to install the enca package on your system before preceding:

sudo apt-get install enca

In a terminal, browse to the directory where the target files are located and use simply enter the following command:

enconv src_filename

The utility should automatically detect the encoding of the source file and convert the file to an Ubuntu compatible UTF-8 version!

Summary

The recode and iconv utilities are pretty powerful and handy if you know the original encoding of your source file. However, econv seems to be the pick of the bunch as it is a cinch to use and will automatically detect the encoding of most text files for you.


28
Jun 10

Mimms: Handy tool to rip MMS MP3 streams to file in Ubuntu

Today, I came across a handy command line tool called mimms that allows you to rip mms:// MP3 streams to an MP3 file on your computer for later listening. It is very easy to install and use.

Install mimms:

sudo apt-get install mimms

Sample usage:

mimms mms://iss-video.leeds.ac.uk/smlc/audio/eas/east3031/03Chopsticks.mp3
mimms mms://iss-video.leeds.ac.uk/smlc/audio/eas/east3031/03Chopsticks.mp3 filename-here.mp3

Of course you can find out more command line options by simply typing mimms –help

Happy ripping!


28
Jun 10

Enable Multimedia and DVD Playback in Ubuntu Lucid

Whilst Ubuntu comes with some basic multimedia support out of the box, there are a few simple steps that must be carried out in order for you to get the most out of your MP3, DVD and video collection.

First we need to add the Medibuntu repository for your version of Ubuntu:

sudo wget http://www.medibuntu.org/sources.list.d/$(lsb_release -cs).list  --output-document=/etc/apt/sources.list.d/medibuntu.list

Next we add the Medibuntu keyring and refresh apt:

sudo apt-get update && sudo apt-get install medibuntu-keyring && sudo apt-get update

Next we need to install some multimedia packages and codecs:

sudo apt-get install non-free-codecs libdvdcss4 w32codecs vlc mplayer

Finally, run this script to enable encrypted DVD playback:

sudo /usr/share/doc/libdvdread4/install-css.sh

There we go, now sit back and relax!