formatting

DecimalFormat variable group size

 ̄綄美尐妖づ 提交于 2019-12-17 17:22:32
问题 I've researched the subject somewhat before posting the question, but I couldn't find the answer. Here is what I'm trying to do: input: a number 7-8 decimal spaces long (no fractions). output: "X XXXXXX X" where X is a digit, must be present. example: 1234567 => 0 123456 7 What I tried: DecimalFormatSymbols group = new DecimalFormatSymbols(); group.setGroupingSeparator(' '); DecimalFormat idFormat = new DecimalFormat("0,000000,0", group); But this prints something like "0 1 2 3 4 5 6 7"

How does one output bold text in Bash?

耗尽温柔 提交于 2019-12-17 17:19:07
问题 I'm writing a Bash script that prints some text to the screen: echo "Some Text" Can I format the text? I would like to make it bold. 回答1: The most compatible way of doing this is using tput to discover the right sequences to send to the terminal: bold=$(tput bold) normal=$(tput sgr0) then you can use the variables $bold and $normal to format things: echo "this is ${bold}bold${normal} but this isn't" gives this is bold but this isn't 回答2: In order to apply a style on your string, you can use a

How to format a number with padding in Erlang

耗尽温柔 提交于 2019-12-17 16:32:29
问题 I need to pad the output of an integer to a given length. For example, with a length of 4 digits, the output of the integer 4 is "0004" instead of "4". How can I do this in Erlang? 回答1: adding a bit of explanation to Zed's answer: Erlang Format specification is: ~F.P.PadModC. "~4..0B~n" translates to: ~F. = ~4. (Field width of 4) P. = . (no Precision specified) Pad = 0 (Pad with zeroes) Mod = (no control sequence Modifier specified) C = B (Control sequence B = integer in default base 10) and

Quotes in XML. Single or double?

岁酱吖の 提交于 2019-12-17 16:31:45
问题 I've heard that using single quotes to surround XML attribute values is a "bad style". Is this correct? Should I always write: <element attr="value"> Or is it acceptable to write: <element attr='value'> Or does it not matter which style I use? 回答1: Both are legal. Choose one and stick with it. It doesn't matter. From the spec: AttValue ::= '"' ([^<&"] | Reference)* '"' | "'" ([^<&'] | Reference)* "'" Showing that both are valid, as is mixing the two styles within an element, per attribute

toLocaleString() not supported in all browsers? [duplicate]

不想你离开。 提交于 2019-12-17 16:28:45
问题 This question already has answers here : Internationalization(Number formatting “num.toLocaleString()”) not working for chrome (4 answers) Closed 6 years ago . i've this simple function: Chrome, Firefox, IE: Number(1000000).toLocaleString() "1 000 000" // in french system, the space is the separator instead of the comma Opera, Maxthon: Number(1000000).toLocaleString() "1000000" why Opera and Maxthon cant format it? they support this method but dont execute it in the right way? is there any

C#: is calling an event handler explicitly really “a good thing to do”?

落花浮王杯 提交于 2019-12-17 16:28:30
问题 This question is related to C#, but may be applicable to other languages as well. I have a reservation against using code such as the following: using System.Windows.Forms; class MyForm : Form { private Timer myTimer; private Button myButton; public MyForm() { // Initialize the components, etc. myTimer.Tick += new EventHandler( myTimer_Tick ); myButton.Click += new EventHandler( myButton_Click ); myTimer.Start(); } private void myTimer_Tick( object sender, EventArgs eventArgs ) { myTimer.Stop

Measuring text in WPF

邮差的信 提交于 2019-12-17 16:04:46
问题 Using WPF, what is the most efficient way to measure a large number of short strings? Specifically, I'd like to determine the display height of each string, given uniform formatting (same font, size, weight, etc.) and the maximum width the string may occupy? 回答1: The most low-level technique (and therefore giving the most scope for creative optimisations) is to use GlyphRuns. It's not very well documented but I wrote up a little example here: http://smellegantcode.wordpress.com/2008/07/03

HTML : How to retain formatting in textarea?

半腔热情 提交于 2019-12-17 15:56:15
问题 I am using HTML textarea for user to input some data and save that to App Engine's model The problem is that when I retrieve the content it is just text and all formatting is gone The reason is because in textarea there is no formatting that we can make Question: is there any way to retain the format that user provides? is there any other element(other than textarea), that i'll have to use?(which one?) P.S I am very new to area of web development and working on my first project Thank you 回答1:

How do I format a number to a dollar amount in PHP

梦想与她 提交于 2019-12-17 15:42:15
问题 How do you convert a number to a string showing dollars and cents? eg: 123.45 => '$123.45' 123.456 => '$123.46' 123 => '$123.00' .13 => '$0.13' .1 => '$0.10' 0 => '$0.00' 回答1: PHP also has money_format(). Here's an example: echo money_format('$%i', 3.4); // echos '$3.40' This function actually has tons of options, go to the documentation I linked to to see them. Note: money_format is undefined in Windows. 回答2: If you just want something simple: '$' . number_format($money, 2); number_format()

What is the best way for converting phone numbers into international format (E.164) using Java?

↘锁芯ラ 提交于 2019-12-17 15:25:22
问题 What is the best way for converting phone numbers into international format (E.164) using Java? Given a 'phone number' and a country id (let's say an ISO country code), I would like to convert it into a standard E.164 international format phone number. I am sure I can do it by hand quite easily - but I would not be sure it would work correctly in all situations. Which Java framework/library/utility would you recommend to accomplish this? P.S. The 'phone number' could be anything identifiable