+charlenni Posted June 6, 2015 Share Posted June 6, 2015 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. Quote Link to comment
+zuge Posted June 6, 2015 Share Posted June 6, 2015 Great work charlenni! Should we wait till new version of Urwigo comes out or does this still somehow work with that little problem? Quote Link to comment
+charlenni Posted June 8, 2015 Author Share Posted June 8, 2015 If you don't use the input encryption, it should work, but it would be much easier with the new version. Quote Link to comment
+zuge Posted June 13, 2015 Share Posted June 13, 2015 (edited) 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 Edited June 13, 2015 by zuge Quote Link to comment
+charlenni Posted June 14, 2015 Author Share Posted June 14, 2015 (edited) Perhaps I had made a mistake. Please try var = rawget(zitemTest, "Description") Hope, this is correct. Could not try it before tomorrow. Edited June 14, 2015 by charlenni Quote Link to comment
+zuge Posted June 14, 2015 Share Posted June 14, 2015 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... Btw, item:rawget("Description") method works at least in Groundspeak Wherigo Player and Garmin Oregon 450. Quote Link to comment
+charlenni Posted June 17, 2015 Author Share Posted June 17, 2015 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. Quote Link to comment
+charlenni Posted June 17, 2015 Author Share Posted June 17, 2015 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. Quote Link to comment
+MrYaz Posted July 9, 2015 Share Posted July 9, 2015 Sorry in advance for the n00bish question... Where can I find the "author script section" in Urwigo? Quote Link to comment
+charlenni Posted July 9, 2015 Author Share Posted July 9, 2015 Argh. I forgot this. In Urwigo it is called "Lua user functions". You could find it in the menu "View". Quote Link to comment
+charlenni Posted February 15, 2016 Author Share Posted February 15, 2016 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. Quote Link to comment
Recommended Posts
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.