[TIMOB-4886] String.format using sequence (%1$s) returns invalid string
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2011-10-27T14:32:11.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Sprint 2011-31, Release 1.8.0 |
Components | iOS |
Labels | string |
Reporter | Matthew O'Riordan |
Assignee | Reggie Seagraves |
Created | 2011-08-03T12:03:20.000+0000 |
Updated | 2011-10-27T14:32:21.000+0000 |
Description
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');
win.add(Titanium.UI.createLabel({
text: text,
color: '#000',
left: 10,
right: 10
}));
win.open();
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
Would you also provide the strings.xml file you used to test this, in a code block in the body of the ticket? Cheers
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
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.
Thanks Paul. I will bear that mind for future tickets.
Tested with 1.8.0.v20110819142548 iPhone 4.3.4 iPad2 4.3.2 Motorola Xoom 3.2 Nexus One 2.2.2