Home > Uncategorized > Removing accents in source code

Removing accents in source code

I very often find source code with accent, mainly comments in french. Some are UTF-8 and other ISO8859. Even if UTF-8 is now largely supported, using it in source code is looking for troubles. Here is a way to remove accents in a text file:

iconv -t ASCII//TRANSLIT myfile.c > myfile_without_accent.c

It will only work if you current locale support it.

ref: http://www.gnu.org/software/libiconv/

UPDATE:

A small script to convert UTF-8 to ASCII (to be used with find):

#! /bin/sh
export LANG=fr_FR.UTF-8
tmp=`mktemp`
iconv -t ASCII//TRANSLIT $1 > $tmp
mv $tmp $1
Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: