Convert text files to utf-8

Dolphin Service Menus

Source (link to git-repo or to original if based on someone elses unmodified work): Add the source-code for this project on opencode.net

0
5 .0
Description:

Convert any text file from latin-1 charset to utf-8
by two mouse clicks.

---------------------------------------------------
About
---------------------------------------------------

After upgrading my Linux box to Suse 9.2, I had a
big problem: In many text(-based) files there didn't
show up any non-ascii characters (e.g. umlauts: äöüß)
any more. Instead there were ugly boxes or even
nothing at all.

It took me quite some googling until I found the
reason and solution: Suse switched their default
encoding to utf-8, so that files from my old system
as well as some new files I encounter from time to
time being encoded in latin-1 don't show up correctly
any more.

The solution is to convert every single of these files
to utf-8 using the command line tool "iconv", which
is part of the c library and therefore should be
present on any Linux system.

To ease things up, I created this KDE service menu which
allows me to convert files with just two mouse clicks
and even works on multiple selected files. So, every
time I encounter another non-utf-8 file, I can continue
working with a corrected file in only a matter of
seconds :-).

As there seem to be many other users with this kind
of problem out there, I decided to share it to you.
So enjoy and drop me a note (kde@benno-dielmann.de)
, if you like it (or if there are problems...)!

---------------------------------------------------
Installation
---------------------------------------------------

Copy the file

iconv-servicemenu.desktop

to

$KDEDIR/share/apps/konqueror/servicemenus/

and you are done!

---------------------------------------------------
Usage
---------------------------------------------------

Select the file(s) to convert and select "convert to
utf-8" from the actions submenu of the right-mouse-
button menu. A new (converted) file with suffix _utf-8
is created in the same directory. The original file is
left untouched, in case anything went wrong ;-).

testerus

15 years ago

How do you detect the encoding of the textfile before converting for utf-8?

Are you using the encoding detection of Konqueror (http://webcvs.kde.org/kdelibs/khtml/misc/) or Mozilla (http://www.mozilla.org/projects/intl/chardet.html)?

Report

C

bendie

15 years ago

;-) In fact, there is no encoding detection at all. Its just a simple wrapper for the command

iconv -f latin-1 -t utf_8 %u -o %u_utf-8

where %u is the selected file. Nothing more. If you have to convert other encodings than latin-1, I suggest you to replace this in the iconv-servicemenu.desktop.

If you know of any method to add automatic detection please let me know. The examples you provide all seem to involve programming exceeding the scope of such a simple service menu entry. Correct me if I'm wrong...

For me personally, there isn't any need for several different input encodings since I use it mainly for converting my old files from my backups (See the lengthy description above...), on which latin-1 works quite well.

If there is anyone out there needing detection of different input encodings, please let me know, so I can think about a way to add it.

Report

12345678910
product-maker Base: 4 x 5.0 Ratings
Be the first to comment
File (click to download) Version Description Downloads Date Filesize DL OCS-Install MD5SUM
*Needs pling-store or ocs-url to install things
Pling
0 Affiliates
Details
license
version
1.0
updated Feb 23 2005
added Feb 23 2005
downloads 24h
2
mediaviews 24h 0
pageviews 24h 2
System Tags addon