String.upper not working on Android devices, works on Simulators and iOS devices

I am using “string.upper” to convert inputted text into all upper case in a listener on a native.newTextField.  See code below.  It works on Simulator on PC, Simulator on Mac, and several iOS devices I tried.  But on several Android devices I tried, the conversion to upper case using string.upper does not work and does nothing.  I tried adding long delays as well like shown below.  Could not find any solution after a lot of searching, so reaching out here for a possible answer.  Thanks!

if ( event.phase == “began” ) then

elseif ( event.phase == “ended” or event.phase == “submitted” ) then

sleep(.25) --tried adding delay as well

PlayerBox[event.target.id].text = string.upper(PlayerBox[event.target.id].text)

PlayerBox[event.target.id].text = string.gsub(PlayerBox[event.target.id].text, “^%s*(.-)%s*$”, “%1”)

PlayerBox[event.target.id].align = “left”

PlayerBox[event.target.id]:setSelection( 1, 1 ) 

also tried…

local upp = string.upper(PlayerBox[event.target.id].text)

PlayerBox[event.target.id].text = upp

Shouldn’t make any difference, but have you tried:

local upp = PlayerBox[event.target.id].text:upper()

happymongoose, good idea to try.  Just tried it and still does not work on actual Android device.

I also just tried hardcoding it like per statement below just to see if it is processing the line.  Works on simulator and changes player name to upper case MICHAEL, but still does not on Android device.  It is doing the other lines in the listener including the other string formatting, so looks like just a problem with the string.upper.  On the surface, it looks like Corona builds the line correctly for iOS but not for Android.  But still looking for more ideas to try to get around it.

PlayerBox[event.target.id].text = string.upper(“michael”)

Try substituting the utf-8 plugin for the string library. In my experience, there’s no downside and with some strings it just works way better.

So instead of string.upper(str), you just call utf8.upper(str).

https://docs.coronalabs.com/plugin/utf8/index.html

That was another good idea to use utf8, but it did not work either.  So I added the plugin in build settings per doc, added local utf8 = require( “plugin.utf8” ) in main.lua, then tried both scenarios below in the listener.  Works on simulator, but still does not  work on actual android device.  

tried…

PlayerBox[event.target.id].text = utf8.upper(PlayerBox[event.target.id].text)

and tried…

local upp = utf8.upper(PlayerBox[event.target.id].text)

PlayerBox[event.target.id].text = upp

Shouldn’t make any difference, but have you tried:

local upp = PlayerBox[event.target.id].text:upper()

happymongoose, good idea to try.  Just tried it and still does not work on actual Android device.

I also just tried hardcoding it like per statement below just to see if it is processing the line.  Works on simulator and changes player name to upper case MICHAEL, but still does not on Android device.  It is doing the other lines in the listener including the other string formatting, so looks like just a problem with the string.upper.  On the surface, it looks like Corona builds the line correctly for iOS but not for Android.  But still looking for more ideas to try to get around it.

PlayerBox[event.target.id].text = string.upper(“michael”)

Try substituting the utf-8 plugin for the string library. In my experience, there’s no downside and with some strings it just works way better.

So instead of string.upper(str), you just call utf8.upper(str).

https://docs.coronalabs.com/plugin/utf8/index.html

That was another good idea to use utf8, but it did not work either.  So I added the plugin in build settings per doc, added local utf8 = require( “plugin.utf8” ) in main.lua, then tried both scenarios below in the listener.  Works on simulator, but still does not  work on actual android device.  

tried…

PlayerBox[event.target.id].text = utf8.upper(PlayerBox[event.target.id].text)

and tried…

local upp = utf8.upper(PlayerBox[event.target.id].text)

PlayerBox[event.target.id].text = upp