Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-4886] String.format using sequence (%1$s) returns invalid string

GitHub Issuen/a
Resolution Date2011-10-27T14:32:11.000+0000
Affected Version/sn/a
Fix Version/sSprint 2011-31, Release 1.8.0
ReporterMatthew O'Riordan
AssigneeReggie Seagraves


When using the String.format function, it works as expected when using the interpolation such as String.format('inserted value is %s', 'expected'). However, when using the sequence syntax such as String.format('inserted value is %1$s', 'expected') garbled characters are returned where the interpolation is expected. Code to replicate this issue below.
var win = Titanium.UI.createWindow({
  backgroundColor: '#FFF'

var text = "String.format with %s interpolation - " + String.format('value = %s', 'correct');
text += "\nString.format with %1$s and %2$s interpolation - " + String.format('value = %1$s %2$s', 'correct1', 'correct2');

  text: text,
  color: '#000',
  left: 10,
  right: 10


  1. Paul Dowsett 2011-08-03

    Matt Thanks for raising this ticket - it is a lot cleaner than your first. With this potential bug, are two files important in order to replicate the issue? Would you test with all your code in app.js to be certain? A single app.js file is always preferable to multiple files. I will correct the environment field for you. Please note these changes, so you know the information to provide with any new tickets. Cheers
  2. Paul Dowsett 2011-08-03

    Would you also provide the strings.xml file you used to test this, in a code block in the body of the ticket? Cheers
  3. Matthew O'Riordan 2011-08-03

    Paul, are you just trying to be difficult? I have provided a perfectly workable testing solution as two files yes, but that DOES NOT EFFECT the issue in any way whatsoever. Every Titanium App is more than one JS file, so why is this an issue? Seriously man, why are you putting up a barrier every time. Please pass this on as is, I have made the effort, now do your part please. Also, if you look at the code, I am not using an Localisation strings, so no strings.xml file is necessary. The L method is never called, I am only using Strings.format
  4. Paul Dowsett 2011-08-03

    OK Matthew, you are now aware of the points to bear in mind, in all the tickets I have edited for you today. These are all explained in the guidelines at [Submitting Bug Reports](http://wiki.appcelerator.org/display/guides/Contributing+to+Titanium#ContributingtoTitanium-SubmittingBugReports), which I urge you to read.
  5. Matthew O'Riordan 2011-08-03

    Thanks Paul. I will bear that mind for future tickets.
  6. Natalie Huynh 2011-08-25

    Tested with 1.8.0.v20110819142548 iPhone 4.3.4 iPad2 4.3.2 Motorola Xoom 3.2 Nexus One 2.2.2

JSON Source