formatting

dealing with nested quotes in html generated from c#

廉价感情. 提交于 2019-12-24 01:58:18
问题 i am using a 3rd party library to show tooltips, like so: string tooltip = "test"; output.Write("onmouseover='Tip(\"" + test + "\");'"); // work fine :) i'm having problem with situations like the following where i need quotes for formatting: string tooltip = "<span style='color:red;'>test</span>"; output.Write("onmouseover='Tip(\"" + test + "\");'"); // no working :( how can i escape the quotes needed for the html in the tooltip so it doesn't break the function call? 回答1: Replace any

How to control length of the result of string.format(bool_value) in Python?

穿精又带淫゛_ 提交于 2019-12-24 01:15:06
问题 What the equivalent way to str.format function for converting booleans into strings? >>> "%5s" % True ' True' >>> "%5s" % False 'False' Please note the space in ' True' . This always makes the length the same for 'True' and 'False'. I've check the methods in this post: How are booleans formatted in Strings in Python? None of them can do the same thing. 回答1: You can use type conversion flags to do what you wanted: '{:_>5}'.format(True) # Oh no! it's '____1' '{!s:_>5}'.format(True) # Now we get

Force date to US format regardless of locale settings

若如初见. 提交于 2019-12-24 00:48:24
问题 I have a VB6 program with this line: strDate = Format(Date, "ddmmmyyyy") I need it to always come out in this format according to the Cultural settings for Windows for English (United States): 17Jul2012 Unfortunately when the culture is set to something else, French, for example, I get this: 17juil2012 Is there any way to make the date format always use the English US formatting? 回答1: Rather than mess about trying to enforce a culture-specific format, why not just hard code the month names

How can I make java.text.NumberFormat format 0.0d as “0” and not “+0”?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-24 00:26:43
问题 Need result with sign, except for 0.0d. Ie: -123.45d -> "-123.45", 123.45d -> "+123.45", 0.0d -> "0". I invoke format.setPositivePrefix("+") on the instance of DecimalFormat to force the sign in the result for positive inputs. 回答1: I'm sure there is a more elegant way, but see if this works? import static org.junit.Assert.assertEquals; import java.text.ChoiceFormat; import java.text.DecimalFormat; import java.text.FieldPosition; import java.text.NumberFormat; import java.text.ParsePosition;

Question about JTextField and text format with numbers?

こ雲淡風輕ζ 提交于 2019-12-23 18:44:42
问题 I writing an application using Swing. My application has a text box and what I want to do is this: when user enters a number in that text field, if the number is in the thousands, then it is automatically appended a comma in the number. For example, if user enters 1000, then it should be automatically changed to 1,000, or 1,000,000 or so. Does anyone give me some ideas, please? 回答1: You can use the DecimalFormat and NumberFormat classes. See an example here; http://www.exampledepot.com/egs

Java text formatting

廉价感情. 提交于 2019-12-23 17:02:02
问题 How can I format a string of text, like givenname, surname, telephone etc to look like columns? this won't do it: String customer = "\t"+surname+"\t"+givenname+"\t"+blablabla 回答1: See the documentation for String.format() . Use maximum length each column can be, plus 1. 回答2: The problem with using tab characters is that their width is dependent on the settings of the console you're using for display, which means you can't guarantee that all columns will line up using this approach. Assuming

git pre-commit hook to format and re-add files at the same time

ε祈祈猫儿з 提交于 2019-12-23 15:47:15
问题 We're currently using a git hook (below) to run astyle on our source code before allowing the user to commit. This has the caveat that the user must commit, have their code formatted, then commit again which is a bit of a nuisance. Ideally we'd want the hook to format the code and then include that formatted code in the original commit instead. I've tried re-adding the changed files but it causes ref errors (obviously). I've also tried getting the history in the pre-commit hook and trying to

PostgreSql: Getting strange-formated “timestamp with time zone”

回眸只為那壹抹淺笑 提交于 2019-12-23 15:16:28
问题 I am inserting into the table with field type "timestamp with time zone" string "1858-11-17 01:09:05+0000" and getting back strage formated value "05:11:29+04:02:24". Here is session test=> create table ddtbl (val timestamp with time zone); CREATE TABLE test=> insert into ddtbl (val) values ('1858-11-17 01:09:05+0000'); INSERT 0 1 test=> select * from ddtbl; val ------------------------------ 1858-11-17 05:11:29+04:02:24 Why is this happening and what is "+04:02:24" here ? UPD: PostgreSQL

eclipse CSS file formatting

不想你离开。 提交于 2019-12-23 13:06:20
问题 I'm trying to make eclipse format css files my way... Currently i've got sth like that: .class{ display: none; sth: other; } But i would like to make it sth like that: .class { display: none; sth: other; } Can I do this? 回答1: I only found in Preferences / Web / Css files / Editor that we can disable "Insert line breaks between props" Other I think is somewhere in the sources of ecl. So even if you know about it -- you could fix it by implementing your own plugin to ecl. 来源: https:/

Write dynamical arrays in Fortran 90 [duplicate]

寵の児 提交于 2019-12-23 12:56:21
问题 This question already has answers here : Format string for output dependent on a variable (4 answers) Dynamic output format setting (2 answers) Closed 2 years ago . I have arrays with dynamical dimension ( dimx , dim ) and I need a way to write such arrays in a file through the Write instruction, the problem is that until now I haven't been able to produce such files in a automatic way, I mean until now I have to change the dimension of the array in the Write instruction by hand and I need a