[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: utf-8 to latin1
- From: Rici Lake <lua@...>
- Date: Tue, 11 Oct 2005 17:34:37 -0500
On 11-Oct-05, at 5:10 PM, Walter Cruz wrote:
Hi. Does anybody have a utf82latin2 function in lua to share? :P
Here's one (for Lua5.1) which isn't very good :)
return (s:gsub("([\192-\255])([\128-\191]*)", function(head, tail)
if head == "\194" and #tail == 1 then
elseif head == "\195" and #tail == 1 then
else return "?"
It does too little error checking, and it doesn't combine diacritics
(i.e. n + combining ~ does not become ñ). So it's only virtue is that
it fits in a short email message.