Foreign letter support

I’m not sure whether this is a Corona bug or to do with the way Lua handles foreign character sets.

For example if I use the following code, the Spanish word “ratón” is displayed correctly …

local word = display.newText("", 0, 0, "Helvetica", 100)  
spanishWord = "ratón"  
word:setTextColor(0, 0, 255)  
word.text = spanishWord  
word.x = display.contentWidth/2  
word.y = display.contentHeight/2  

However, if I try this …

local wordSound = audio.loadSound("ratón.mp3")  
audio.play(wordSound, {channel = 1})  

… I get a resource not found error (but you can play the file ratón.mp3 in Quicktime OK, so it’s a valid OSX filename but what about iOS?).

The reason it may be a Lua issue is that if I do any string manipulation on “ratón” I run into problems. For example, Lua returns a string length of 7 character with the following byte codes (114, 97, 116, 111, 204, 129, 110). So the letter ó is represented by 3 bytes (111, 204, 129).

So is this a bug in Corona or a peculiarity of Lua? Either way is there a work around? [import]uid: 2646 topic_id: 8581 reply_id: 308581[/import]

Anyone at Ansca have a view on this??

Here is some more test code …

local word = display.newText("", 0, 0, "Helvetica", 100)  
spanishWord = "ratón"  
word:setTextColor(0, 0, 255)  
word.text = spanishWord  
word.x = display.contentWidth/2  
word.y = display.contentHeight/2  
print(spanishWord, #spanishWord)  
for i=1, #spanishWord do  
 print (string.byte(spanishWord, i), string.char(string.byte(spanishWord, i)))  
end  
print(string.char(236)) -- this is the code for letter ó (o acute)  
local wordSound = audio.loadSound("ratón.mp3")  
audio.play(wordSound, {channel = 1})  

The word ‘ratón’ displays correctly on screen but the terminal output is …

Copyright © 2009-2010 A n s c a , I n c .
Version: 2.0.0
Build: 2011.336
The file sandbox for this project is located at the following folder:
(/Users/stefan/Library/Application Support/Corona Simulator/Pomme Test-1F572E7EC0E5232BF68C66D1C2BFE7E1)
ratón 7
114 r
97 a
116 t
111 o
204 ?
129 ?
110 n
?
WARNING: Cannot create path for resource file ‘ratón.mp3’. File does not exist.

WARNING: Failed to create audio sound (ratón.mp3)
[import]uid: 2646 topic_id: 8581 reply_id: 31092[/import]

+1 I need this to work too. Please fix. [import]uid: 10426 topic_id: 8581 reply_id: 32306[/import]

I’m trying a workaround with gsub http://developer.anscamobile.com/reference/index/stringgsub :

This works:
[lua] spanishtext = “mamá”
spanishtextv2 = spanishtext:gsub( “á”, “a-tc” )
local wordSound = audio.loadSound(spanishtextv2…".wav")
audio.play(wordSound) – will play “mama-tc.wav”
print( spanishtextv2 )[/lua]

But I can’t make it work with tables:
[lua] spanishtextv2 = spanishtext:gsub(".",{a=“a-tc”}) --Works with a
spanishtextv2 = spanishtext:gsub(".",{á=“a-tc”}) --Doesn’t work with á[/lua]

The code in this page fails too http://forum.luahub.com/index.php?topic=1688.0

Anyone?
[import]uid: 10426 topic_id: 8581 reply_id: 32327[/import]

the lua string functions len, sub, reverse do not work with characters other than those of the latin alphabet. you might find this useful

http://developer.anscamobile.com/forum/2010/08/08/string-greek-characters

[import]uid: 6459 topic_id: 8581 reply_id: 32343[/import]