Author Topic: How to type accentuated characters in a Lua script without having bug..  (Read 5919 times)

0 Members and 1 Guest are viewing this topic.

Offline Loulou 54

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 165
  • Rating: +39/-0
    • View Profile
    • Mes programmes sur TI bank.
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. :)

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. :)
« Last Edit: December 10, 2011, 04:44:45 pm by Loulou 54 »
Some of my program available here.. :)
http://ti.bank.free.fr/index.php?mod=archives&ac=voir2&id=1471

     

Offline Chockosta

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 447
  • Rating: +169/-6
    • View Profile
Re: How to type accentuated characters in a Lua script without having bug..
« Reply #1 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())

Offline Loulou 54

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 165
  • Rating: +39/-0
    • View Profile
    • Mes programmes sur TI bank.
Re: How to type accentuated characters in a Lua script without having bug..
« Reply #2 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 ?
Some of my program available here.. :)
http://ti.bank.free.fr/index.php?mod=archives&ac=voir2&id=1471

     

Offline Adriweb

  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1708
  • Rating: +229/-17
    • View Profile
    • TI-Planet.org
Re: How to type accentuated characters in a Lua script without having bug..
« Reply #3 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 :-)
My calculator programs
TI-Planet.org co-admin.
TI-Nspire Lua programming : Tutorials  |  API Documentation

Offline Loulou 54

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 165
  • Rating: +39/-0
    • View Profile
    • Mes programmes sur TI bank.
Re: How to type accentuated characters in a Lua script without having bug..
« Reply #4 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..
Some of my program available here.. :)
http://ti.bank.free.fr/index.php?mod=archives&ac=voir2&id=1471

     

Offline Chockosta

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 447
  • Rating: +169/-6
    • View Profile
Re: How to type accentuated characters in a Lua script without having bug..
« Reply #5 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
« Last Edit: December 11, 2011, 01:44:49 pm by Chockosta »

Offline Nick

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1166
  • Rating: +161/-3
  • You just got omnom'd
    • View Profile
    • Nick Steen
Re: How to type accentuated characters in a Lua script without having bug..
« Reply #6 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

Offline Loulou 54

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 165
  • Rating: +39/-0
    • View Profile
    • Mes programmes sur TI bank.
Re: How to type accentuated characters in a Lua script without having bug..
« Reply #7 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.
« Last Edit: December 17, 2011, 11:48:46 am by Loulou 54 »
Some of my program available here.. :)
http://ti.bank.free.fr/index.php?mod=archives&ac=voir2&id=1471