lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> Does anybody happen to have a mapping (or an algorithm) that will
> remove diacritical marks from strings?  I'd like to convert Jérôme to
> Jerome and that sort of thing.

Try something like this (untested):

local t={
	['A'] = "ÀÁÂÃÄÅ",
	['E'] = "èéêë",
	...
}

local T={}
for i=0,255 do
	local c=string.char(i)
	T[c]=c
end
for k,v in pairs(t) do
	for i=1,#v do
		T[v:sub(i,i)]=k
	end
end

now use string.gsub(source,"(.)",T)
--lhf