formatting

Rendering HTML inside a DataList

I have a formatted text that contains Bolded, italicsed, and other styles implemented inside the message. I have this message stored in a Database. Now I want to implement these tags into work inside the a field inside the DataList. How do I do it? <%# Eval("message") %> Doesn't work. It just shows up the tags as such. Any help? ...

How do I convert a decimal to string value for dollars and cents in ruby?

I am storing a cost in my application. The cost is not formatted in the database. For example: 00.00 saves as 0, 1.00 saves as 1, and 40.50 saves as 40.5 I need to read these values from the database and convert them to strings for dollars and cents. For example: 0 --> cost_dollars = "00" & cost_cents = "00", 1 --> cost_dollars = "01...

VB.net Decimal.toString() for any Region

I have an app that deals with currency. For display purposes I use the nifty VB FormatCurrency function which will format based on the OS's region setting. So, if in France you might get 123,45 where in the US you would get 123.45. To perform calculation on these amounts I use CDec() to convert to decimal. My problem is that when I c...

Timestamps look different

In Rails, I find that timestamps in the console look different to the actual html view even when you have the same code. Unless I'm doing something really stupid: >> article = News.first => #<News id: 1, title: "Testing", body: "yadda yadda", role_id: 1, created_at: "2009-04-12 05:33:07", updated_at: "2009-04-12 05:33:07"> >> article.cr...

How do I format a Decimal to a programatically controlled number of decimals in c#?

How can I format a number to a fixed number of decimal places (keep trailing zeroes) where the number of places is specified by a variable? e.g. int x = 3; Console.WriteLine(Math.Round(1.2345M, x)); // 1.234 (good) Console.WriteLine(Math.Round(1M, x)); // 1 (would like 1.000) Console.WriteLine(Math.Round(1.2M, x)); // 1.2 (w...

Printing thousand seperated floats with GAWK

I must process some huge file with gawk. My main problem is that I have to print some floats using thousand separators. E.g.: 10000 should appear as 10.000 and 10000,01 as 10.000,01 in the output. I (and Google) come up with this function, but this fails for floats: function commas(n) { gsub(/,/,"",n) point = index(n,".") - 1 if ...

Use a custom thousand separator in C#

Hi, I'm trying not to use the ',' char as a thousand separator when displaying a string, but to use a space instead. I guess I need to define a custom culture, but I don't seem to get it right. Any pointers? eg: display 1000000 as 1 000 000 instead of 1,000,000 (no, String.Replace() is not the solution I'd like to use :P) ...

Visual Studio code formatter

I'm using VisualStudio 2008 for doing work in C# and JavaScript (AJAXy stuff). Here's my issue -- I love Eclipse and especially the code formatted (Ctrl-Shift-F). Visual Studio's Ctrl-k, Ctrl-d, really sucks in comparison, especially for javascript. Is there a way to get VS to behave like the IDE that I miss? TIA, g ...

Rounding numbers in Objective-C

Hi, I'm trying to do some number rounding and conversion to a string to enhance the output in an Objective-C program. I have a float value that I'd like to round to the nearest .5 and then use it to set the text on a label. For example: 1.4 would be a string of: 1.5 1.2 would be a string of: 1 0.2 would be a string of: 0 I've spe...

Java: Currency to Locale Mapping Possible?

I have a value stored in a DB correlating to a monetary amount, say 10.0. I also have access to the Currency/CurrencyCode. How can I use NumberFormat/DecimalFormat/(other?) to format when I don't know the Locale? According to the docs it will pick a default locale which won't work with a foreign Currency. ...

PowerBuilder: international currency formatting

Background Users in the US were our application's initial user base, but this has expanded to the point that Canadian, British, and Scandinavian users also use the system. The PowerBuilder datawindow didn't like the Scandinavian currency format with decimals and periods transposed (###.###,00). When we tried to set the format in the d...

How can I insert source code from Xcode into OpenOffice without getting an paragraph for every single line?

That's important for good documentation, but currently it just doesnt work well. If I copy source code from Xcode editor into OpenOffice Writer, then every single line is an own paragraph. I have a paragraph style for source code, but because of multiple paragraphs I get a lot of unnecessary spaces. Could i program a macro that combines...

Is it possible to format a NumberField in a page layout?

I'm developing a SharePoint publishing site and setting up its content types and page layouts. I need to display the value for a Year field with type Number. The markup currently is: <SharePointWebControls:NumberField FieldName="Year" runat="server" id="Year" /> The problem with the default behaviour is that it shows each number with ...

Ruby on Rails - how to display a date in format i need? Converting from YYYY-MM-DD HH:MM:SS UTC to MM/DD/YYYY

I am a RoR newbie. I tried a lot of things, finally came to following: <td> <%= Date.strptime(request.baseline_start_date, "%Y-%M-%D %H:%M:%S %Z").strftime("%M/%D/%Y")%> </td> But this is also giving me an error: $_ value need to be String (nil given) But I know that request.baseline_start_date gives me value (tried printing it se...

Manage XML documents in subversion ignoring formatting

I need to manage XML documents in Subversion but don't want to manage the formatting which may turn out differently depending on who is editing the file. I see two solutions: Either format the file each time with a known formatting before checking in. Or give svn a diff program that actively dismisses formatting from the diff algorithm....

MVC Views and the {

Duplicate: How do you get server blocks <% %> to format well in Visual Studio? Working with MVC Views, the Visual Studio editor keeps reformatting my code to look like this: <% foreach (var day in week.Days) { %> I'm trying to keep the MVC View as clean as possible, I'd rather it just look like: <% foreach (var day in w...

Suggestions for a good Content Formatting Library

I am trying to implement a content formatting feature in my website - that is, I want to let my users type for example [b]bold[/b] or (like SO) * * bold * * and end up with bold. I also want support for headers, links, images etc. The more I'm working on this, the more I feel like I'm reinventing the wheel. If possible, I would like to ...

How to format autogenned columns in ASP.Net GridView?

Until now, I've always explicitly formatted every column in my GridView. But now, my datasource can vary in number of columns, so I autogenerate="true" That leaves me with no place to define the format, so all the non-string fields have four decimal places when I want two-decimal accounting format. ...

Unexpected java SimpleDateFormat parse exception

I can't understand why this few lines Date submissionT; SimpleDateFormat tempDate = new SimpleDateFormat("EEE MMM d HH:mm:ss z yyyy"); public time_print(String time) { try { submissionT=tempDate.parse(time); } catch (Exception e) { System.out.println(e.toString() + ", " + tim...

Getting rid of spaces in a string

To add a whitespace seperator in a string we use String.Join(). My question:What(and how) do I have to remove that seperator. The string's structure is the following "FF FF FF FF FF FF FF FF FF...." How do I remove the white spaces? ...