Jump to content
Sign in to follow this  
Followers 3
charlenni

Garmins and special characters

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.

Share this post


Link to post

Great work charlenni! :)

 

Should we wait till new version of Urwigo comes out or does this still somehow work with that little problem?

Share this post


Link to post

If you don't use the input encryption, it should work, but it would be much easier with the new version.

Share this post


Link to post

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

Share this post


Link to post

Perhaps I had made a mistake.

 

Please try

 

var = rawget(zitemTest, "Description")

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

Edited by charlenni

Share this post


Link to post

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.

Share this post


Link to post

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.

Share this post


Link to post

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.

Share this post


Link to post

Sorry in advance for the n00bish question...

 

Where can I find the "author script section" in Urwigo?

Share this post


Link to post

Argh. I forgot this. In Urwigo it is called "Lua user functions". You could find it in the menu "View".

Share this post


Link to post

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.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
Followers 3

×