Page 1 of 1
convert_utf8_ascii error
Posted: Sun Oct 11, 2009 4:58 am
by master121
Code: Select all
unction convert_utf8_ascii_character( _str, _ascii )
local found;
local tmp = database.utf8_ascii[_ascii];
_str, found = string.gsub(_str, string.char(tmp.utf8_1, tmp.utf8_2), string.char(tmp.ascii) );
return _str, found;
end
function convert_utf8_ascii( _str )
local found, found_all;
found_all = 0;
for i,v in pairs(database.utf8_ascii) do
_str, found = convert_utf8_ascii_character( _str, v.ascii ); -- replace special characters
found_all = found_all + found; -- count replacements
end
if( found_all > 0) then
return _str, true;
else
return _str, false;
end
end
When i call it like this :
Code: Select all
local bagid, icon, name, itemCount = sendMacro("GetBagItemInfo("..k..");");
dofile("string.lua")
name = convert_utf8_ascii(name);
It ends in this error.
string.lua:4 attempt to index local "tmp" <a nil value>
Any solution ?
Re: convert_utf8_ascii error
Posted: Sun Oct 11, 2009 7:25 am
by Administrator
Why are you loading string.lua? It's not part of the bot, so I don't know what it contains. But that's where your error is.
Re: convert_utf8_ascii error
Posted: Sun Oct 11, 2009 7:49 am
by master121
function convert_utf8_ascii_character( _str, _ascii ) and function convert_utf8_ascii( _str ) are in there.
I think d003232 gave me the functions.
Re: convert_utf8_ascii error
Posted: Sun Oct 11, 2009 7:56 am
by Administrator
If you've got the latest version off of SVN, you should not need string.lua. rom/functions.lua already contains the function you are trying to use.
Re: convert_utf8_ascii error
Posted: Sun Oct 11, 2009 2:25 pm
by d003232
master121 wrote:function convert_utf8_ascii_character( _str, _ascii ) and function convert_utf8_ascii( _str ) are in there.
I think d003232 gave me the functions.
In the latest SVN, the function for conversion of umlauts was renamed to
Code: Select all
function utf8ToAscii_umlauts(_str)