Jump to content

Garmins and special characters


charlenni

Recommended Posts

Hello,

 

today I would like to present a library, that allows to use special characters on Garmins. It is usefull for Urwigo or hand made cartridges. Earwigo could handle this by default. It assumes, that cartridge code uses UTF-8 for strings.

 

The problem is, that all players use UTF-8 as string encoding except Garmins. They use ISO-8859-1. If you use any special character on Garmins, you get the "?" sign instead of the expected character. Because the ISO-8859-1 has some special characters more than 7-bit ASCII, we could use this on Garmins. For this, the library is made.

 

On non Garmin devices nothing is changed.

 

What does work?

All names, descriptions, inputs and commands are translated on Garmins from UTF-8 to Latin. Results of inputs are converted back from Latin to UTF-8. Even if you save the cartridge all works ok. It works with encrypted strings too.

 

Additionally the library contains workarounds for the following Garmin bugs:

- ShowScreen Bug: Crash when showning a screen other than mainscreen

- Input Bug: Crash when input is on screen and another screen pops up

- Timer Bug: Problem to stop timer in OnTick

 

What doesn't work?

You couldn't get strings back correctly. If you use "var = item.Name" you get on Garmins a Latin string. So you should use "var = item:rawget("Name")" to get the UTF-8 string.

 

Up to now there is a little problem with encrypted answers in Urwigo. This should be corrected in the next version of Urwigo.

 

How to use?

Copy the content of Lua file from GitHub into your author script section of your cartridge. That's all. To create a GWZ file use the UTF-8 version in Urwigo or an UTF-8 editor for hand made cartridges.

 

For testing, you could find a ready made cartridge on GitHub too.

 

If you find any bugs, it would be nice, if you post them here.

 

I hope you enjoy it.

Link to comment

WhereYouGo crashes (you hit a bug! please report...) if I use any item:rawget("Name") or Description... :(

 

I have added a simple code to example cartridge, which is using that rawget. See the attachment. Am I using it wrongly?

 

Here is the code: https://dl.dropboxusercontent.com/u/6802326/Wherigo/Garmin_UTF-8.gwz

 

For some reason the attachment isn't showing to me now, so here is the link to it: https://dl.dropboxusercontent.com/u/6802326/Wherigo/Garmin_UTF-8.jpg

post-4876565-092527900 1434197442_thumb.jpg

Edited by zuge
Link to comment

Perhaps I had made a mistake.

 

Please try

 

var = rawget(zitemTest, "Description")

Hope, this is correct. Could not try it before tomorrow.

 

Thanks! That sure seems to work fine in WhereYouGo, but gives nil in Groundspeak Wherigo Player... :blink:

 

Btw, item:rawget("Description") method works at least in Groundspeak Wherigo Player and Garmin Oregon 450.

Link to comment

Sorry for the delay. I'm very busy in the moment.

 

Add

 

-- Add a missing rawget
Wherigo.Get = function (obj, prop)
 if string.sub(Env.Platform, 1, 6) == "Vendor" then
   return obj.rawget(obj, prop)
 else
   return obj[prop]
 end
end

to your author script and than use

 

var = Wherigo.Get(item, "Name")

I tested this on Garmin, Emulator, WhereYouGo and iPhone. I updated the GitHub repository too.

Link to comment

Sorry for the delay. I'm very busy in the moment.

 

Add

 

-- Add a missing rawget
Wherigo.Get = function (obj, prop)
 if string.sub(Env.Platform, 1, 6) == "Vendor" then
   return obj.rawget(obj, prop)
 else
   return obj[prop]
 end
end

to your author script and than use

 

var = Wherigo.Get(item, "Name")

I tested this on Garmin, Emulator, WhereYouGo and iPhone. I updated the GitHub repository too.

Link to comment

Yourself published his new version of Urwigo with UTF-8 support. With this, you could use UTF-8 even in the emulator to test it. Thank you for this again.

 

While looking to the Garmin-UTF8 library I encountered, that it is easier to use in Urwigo, when you use it as Lua inline library. So copy the Garmin-UTF8.lua file to your cartridge directory, check the "Inline Lua 'require'" in the cartridge settings and add the following line to the "Lua user functions"

 

require "Garmin-UTF8"

That's all.

 

Even if you don't want to use UTF-8 characters in your cartridge, it is a good idea to use the library, because of the workarounds for the Garmin bugs.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...