Omnimaga

Calculator Community => TI Calculators => Lua => Topic started by: Loulou 54 on December 10, 2011, 04:33:05 pm

Title: How to type accentuated characters in a Lua script without having bug..
Post by: Loulou 54 on December 10, 2011, 04:33:05 pm
Hi everyone. :)

I have a problem that I've already noted before, but it wasn't important in that situation. (in ABA Logique)

Now it becomes annoying.. This is for my traductor (http://ourl.ca/13193). :)

I've already had many problems with the accentuated characters from the word-lists but now it works.

Here is actually the problem that many would have already noted, I suppose :
when I get some special character with the on.charIn event, it produces bugs (displays chinese character or whatever..) and sometimes the following error:
Illegal unicode character in string.

How to avoid this ?
Thanks. :)
Title: Re: How to type accentuated characters in a Lua script without having bug..
Post by: Chockosta on December 10, 2011, 05:22:28 pm
I've never had problems with on.charIn()
All the problems that I've had were with string.sub() (which I just had to replace with string.usub())
Title: Re: How to type accentuated characters in a Lua script without having bug..
Post by: Loulou 54 on December 11, 2011, 11:54:10 am
You can type an accentuated character without bugs ? With this kind of code, I get chinese characters or other bugs..

Code: [Select]
function on.charIn(ch)
msg=string.sub(msg,1,pos)..ch..string.sub(msg,pos+1)   -- pos is the position where you insert what you're typing.
pos=pos+1
end

Maybe you do that in an other way ?
Title: Re: How to type accentuated characters in a Lua script without having bug..
Post by: Adriweb on December 11, 2011, 12:24:56 pm
We have asked (Jim, I believe) TI to put some more unicode support, so maybe it will be better soon :-)
Title: Re: How to type accentuated characters in a Lua script without having bug..
Post by: Loulou 54 on December 11, 2011, 12:30:02 pm
So it's more or less normal for the moment and I can't avoid it ?

Otherwise I could make a kind of a special character menu..
Title: Re: How to type accentuated characters in a Lua script without having bug..
Post by: Chockosta on December 11, 2011, 01:44:33 pm
Why don't you use string.usub() instead of string.sub() ?

In my opinion, it should work
Title: Re: How to type accentuated characters in a Lua script without having bug..
Post by: Nick on December 11, 2011, 02:05:57 pm
if you type é,è,à.. in it, it won't work, whatever string manipulation you use, nspire lua just doesn't recognizes them.
When you run it in the emulator (student/teacher software) it will just shut down, no error or something else, it just can't handle them
Title: Re: How to type accentuated characters in a Lua script without having bug..
Post by: Loulou 54 on December 17, 2011, 11:48:38 am
Why don't you use string.usub() instead of string.sub() ?

In my opinion, it should work

Oh yes indeed ! Sorry. ^^
Thank you ! :D

Solution : use string.usub instead of string.sub function.