formatted

Formatting output with printf: truncating or padding

☆樱花仙子☆ 提交于 2020-01-02 05:42:06
问题 I would like to produce the following output: > Avril Stewart 99 54 > Sally Kinghorn 170 60 > John Young 195 120 > Yutte Schim... 250 40 As you can see, names shorter than 14 characters are padded with spaces. Names longer than 15 characters are truncated: 'Yutte Schimmelpenninck' truncates to 'Yutte Schim...'. Here is what I have tried to achieve this (the variables $name , $height , and $weight are extracted from files, and a loop runs the printf command on each file data): printf '%-14s -

Android strings.xml resource - arabic language and dynamic formatted strings

烈酒焚心 提交于 2020-01-02 02:19:06
问题 Hello I have a question about arabic formatting how should I properly format this strings, it seems i can't manage this: تحميل %1$s… تم تحميل الكلمات. %1$d/%2$d! This is in sublime text 2 - but i think that there is Left-to-Right order EDITED: In Eclipse this copied from Sublime Text gets messed up a little. I hire some person to translate from english to arabic strings.xml. He used Word editor but things get messed up when coping to eclipse and I suggested to changed it in Sublime Text, that

NSLocalizedString(key: value: comment: ) with variable is not working in swift

蓝咒 提交于 2019-12-25 08:07:05
问题 I need to localize a string which has some variable and the localized string must be defined with key: value: comment format. Guys I tried many ways but don't get the right way yet. See here... let timeValue = 5 let timeString = "hours" //Bellows are working fine dateLabelString = String(format: "Overdue by %d %@", timeValue,timeString) //Working //Normal flat string dateLabelString = String(format: NSLocalizedString("Overdue by %d %@", comment: "Overdue by 5 days/hours/minutes/seconds"),

Formatted printing in Java

徘徊边缘 提交于 2019-12-22 06:49:48
问题 I have this code: public String toString(Day day) { String s = day.getDayName() + " " + day.toString(); return s; } This is Day class's toString method: public String toString() { String s = ""; for (Slot slot: slots) s += slot.toString(); return s; } When called over and over again it prints: barbi monday 10: X 11: 12: 2: 3: 4: tuesday 10: 11: 12: 2: 3: 4: X wednesday 10: 11: 12: 2: 3: 4: thursday 10: 11: 12: 2: 3: 4: friday 10: 11: 12: 2: 3: 4: bobbi monday 10: 11: 12: 2: 3: 4: tuesday 10:

How do I use strlen() on a formatted string?

社会主义新天地 提交于 2019-12-20 07:18:45
问题 I'd like to write a wrapper function for the mvwprint/mvwchgat ncurses functions which prints the message in the specified window and then changes its attributes. However, mvwchgat needs to know how many characters it should change - and I have no idea how to tell mvwchgat how long the formatted string is, since a strlen() on, for instance, "abc%d" obviously returns 5, because strlen doesn't know what %d stands for ... 回答1: In C99 or C11, you can use a line like this: length = snprintf(NULL,

Nicely formatting output to console, specifying number of tabs

假如想象 提交于 2019-12-18 10:38:12
问题 I am generating a script that is outputting information to the console. The information is some kind of statistic with a value. So much like a hash. So one value's name may be 8 characters long and another is 3. when I am looping through outputting the information with two \t some of the columns aren't aligned correctly. So for example the output might be as such: long value name 14 short 12 little 13 tiny 123421 long name again 912421 I want all the values lined up correctly. Right now I am

Take Excel cell content and place it into a formatted .txt file

折月煮酒 提交于 2019-12-13 08:03:48
问题 So I have an Excel document, which is essentially a table. For the purposes of this, we will use this: Dummy Data What I'm wanting to do is take the values from these cells and place them into a .txt file. However the text file has some required formatting, and follows a pattern per 'entry' (row) of the spreadsheet. E.g. *********** **THIS IS A FANCY TEXT FILE** *********** <Start of entry text> Predefined text here (Entry 1): $A1 Predefined text here: $B1,$C1 Predefined text here: $D1,$E1,

Formatting output with printf: truncating or padding

纵饮孤独 提交于 2019-12-05 18:47:17
I would like to produce the following output: > Avril Stewart 99 54 > Sally Kinghorn 170 60 > John Young 195 120 > Yutte Schim... 250 40 As you can see, names shorter than 14 characters are padded with spaces. Names longer than 15 characters are truncated: 'Yutte Schimmelpenninck' truncates to 'Yutte Schim...'. Here is what I have tried to achieve this (the variables $name , $height , and $weight are extracted from files, and a loop runs the printf command on each file data): printf '%-14s -%3s -%3s\n' "$name" "$height" "$weight" > Avril Stewart 99 54 > Sally Kinghorn 170 60 > John Young 195

Formatted printing in Java

 ̄綄美尐妖づ 提交于 2019-12-05 09:42:44
I have this code: public String toString(Day day) { String s = day.getDayName() + " " + day.toString(); return s; } This is Day class's toString method: public String toString() { String s = ""; for (Slot slot: slots) s += slot.toString(); return s; } When called over and over again it prints: barbi monday 10: X 11: 12: 2: 3: 4: tuesday 10: 11: 12: 2: 3: 4: X wednesday 10: 11: 12: 2: 3: 4: thursday 10: 11: 12: 2: 3: 4: friday 10: 11: 12: 2: 3: 4: bobbi monday 10: 11: 12: 2: 3: 4: tuesday 10: 11: 12: 2: 3: 4: wednesday 10: 11: 12: 2: 3: 4: thursday 10: 11: 12: 2: X 3: 4: friday 10: 11: 12: 2: 3

Android strings.xml resource - arabic language and dynamic formatted strings

泄露秘密 提交于 2019-12-05 05:11:26
Hello I have a question about arabic formatting how should I properly format this strings, it seems i can't manage this: تحميل %1$s… تم تحميل الكلمات. %1$d/%2$d! This is in sublime text 2 - but i think that there is Left-to-Right order EDITED: In Eclipse this copied from Sublime Text gets messed up a little. I hire some person to translate from english to arabic strings.xml. He used Word editor but things get messed up when coping to eclipse and I suggested to changed it in Sublime Text, that I think will support it correctly like in Eclipse and is lighter editor. I see that in Sublime Text