A generic term meaning the process by which text transformed into a more meaningful or clearer output. A typical example would be the transformation of a decimal into a particular currency format with the correct number of decimal places.

learn more… | top users | synonyms

1
vote
1answer
9 views

Right justified table printer function

A challenge in the beginner book "Automate the boring stuff": ...
2
votes
1answer
17 views

Comparing XML string with different formats

I need to compare 2 xml strings where the formatting may be different. The approach is to use the XmlWriterSettings to format both strings and compare the formatted ...
-1
votes
1answer
31 views

Construct: (un)dumping bytes to hex

This code is part of the Construct library. Docstrings explain what the code is supposed to do. ...
3
votes
2answers
34 views
5
votes
3answers
82 views

Reverse input program in C99

I am writing simple program to reverse its input and output the reversed version. I came up with this code. So how can I improve it? Something tells me that ...
2
votes
2answers
60 views

Spaces-to-tabs converter, updated version

I recently posted Spaces To Tabs Converter but it had lots of bugs, so I rewrote the code. I wanted to ask, is it good code? I didn't find any bugs. ...
3
votes
0answers
19 views

Recursively list files in provided directory in the style of `npm ls`

I've written a small CLI node program to list the contents of a directory with an output similar to that provided by npm ls but listing both files and directories, ...
1
vote
1answer
60 views

Spaces to tabs converter

I wrote a program to convert spaces to tabs. If there are 4 spaces it should convert them to tab. Please let me know how to improve it. ...
4
votes
1answer
32 views

Integer-to-ASCII algorithm (x86 assembly)

This is my best effort at converting a 32 bit integer in EAX, to an 8 character ascii string (result in RDI). It will work ...
3
votes
0answers
19 views

Formatting XML strings in JavaScript for readability

I've created a vanilla JS function to indent XML strings so they can be more easily read. It uses some pretty nasty regex...yes, I know it's a cardinal sin for XML/HTML, but it works. For instance, ...
6
votes
0answers
44 views

A Version 4 UUID Implementation

I've been toying around with writing a decentralized, P2P application in REBOL 2, and one of the things I need to do is generate a universally unique identifier for users. I have written a function ...
0
votes
1answer
14 views

colorprint - part 2

This is a followup of the last review to comply with meta's rules. In the last, I posted a small library called colorprint and got some helpful pointers from chux ...
3
votes
1answer
21 views

colorprint - An ANSI Escape sequence console writer mini-library

I wrote this a long time ago. I came back to it and decided to clean it up a little. It uses the preprocessor and C99 anon structs to make a flexible python-like ...
6
votes
3answers
394 views

Wrapping single line string to multiple lines with specific length

Problem A single line should be separated by Environment.NewLine so that each row has a length of columns (expect for the last ...
1
vote
3answers
67 views

Haskell function to format a floating-point number with some precision

I have not yet developed a satisfying coding style in Haskell. In the code snippet below, there is a lot wrong to my taste: Helper functions which should be local to ...
3
votes
1answer
40 views

Using a MutationObserver to reformat numbers in the user's locale

I mostly just want to make sure I've understood the specs correctly with this code, but here goes: ...
5
votes
1answer
36 views

Create monthly calendar with number of days and offset (day of week) as user input

I am taking a beginning programming class and have been given the assignment to create a calendar as described in the title. Per the assignment the user entering offset of 0 will begin the calendar ...
5
votes
1answer
32 views

Customized date and time display

A simple reworking of the Bash date command to my own personal liking. Possibly a rather trivial task; I just wanted the date and time to be in the form of: <...
4
votes
3answers
97 views

Convert length of time to appropriate unit

I have a time, in seconds, which has the possibility to be very large. I wish to convert said time into the "appropriate" rounded, readable format. I already have code which achieves this, however it'...
4
votes
2answers
124 views

Output two columns

Output formatting: Input Format Every line of input will contain a String followed by an integer. Each String will have a maximum of 10 alphabetic characters, and each integer will be in ...
3
votes
2answers
112 views

Formatting seconds as days hours minutes seconds

I have the below and it gives me the desired output (ie; 1 day 12:05:33) but it looks overly complicated, is there a more straight forward way of doing this with the least amount of string ...
3
votes
1answer
45 views

Formatting a phone number

I have a program that will format a phone number in this format: (###)###-#### ...
6
votes
0answers
117 views

Custom string formatters

Some time ago I was experimenting with an Extendable format provider but I wasn't satisfied with the implementation. It didn't feal very SOLID so I've rewritten it to this: The base class is the <...
9
votes
1answer
187 views

Poor man's f-strings in Python 2.6

f-strings is a new feature in the upcoming python release which basically lets you do this: >>> s = 'qwerty' >>> f'{s} {1+2}' 'qwerty 3' Not ...
6
votes
3answers
79 views

Table printing code using a fluent interface

Let's say you want to display something like: One Two Three Four 1 2 3 4 And since you hate the idea of predefining the widths of the columns you ...
3
votes
3answers
72 views

Java number formatting in accountant style

I have written a string number formatter. I would like to know if this can be improved and any suggestions with how it's done. The purpose of this function is to convert a double that has been ...
0
votes
0answers
28 views

Servlet to generate HTML printable form

I'm using a java servlet to generate HTML code to produce a printable form. I want the form to look like the paper version being used now (or as close as possible) to reduce confusion during the ...
0
votes
1answer
49 views

Convert NSInteger into NSString

This is my sample code to convert a integer into string. Is it very costly to do the multiple loops of [NSMutableString stringWithFormat:..]? I.e should I just use appendString and get the NSString ...
3
votes
1answer
124 views

Formatting a dirty phone number

Given a String that can contain : digits spaces - / I need to format to 3 digits group phone number : example : "55 5/372-6-5/4" should be ...
4
votes
2answers
73 views

F# function to concatenate some DSL scripts with indentation

I'm rather new to F# and functional programming. I wrote the following method to concatenate some custom dsl scripts. The function works are expected without errors. I wanted to know if there was a ...
3
votes
1answer
50 views

Pretty print a 2D matrix in C (numpy style)

Works for any 2D matrix represented by a 1D array. Comments and criticism welcome. Also wondering whether the code can be made shorter. It's really messy right now. ...
2
votes
2answers
31 views

__str__ method for a tic-tac-toe board

I am making my first object-oriented program in python and I am having trouble with the __str__ part of Board() class. I want it ...
8
votes
2answers
60 views

My own snprintf implementation in C

I decided to make my own version of snprintf in C. I intentionally changed some things though. My version guarantees the buffer printed to will be null-terminated, ...
0
votes
1answer
58 views

Pretify JSON class -followup

This is a follow up to this question. This is an improved version in accordance to comments, suggestions and reviews. Is the namespace implementation proper? is the code readable? I didn't want to ...
10
votes
3answers
1k views

Prettify JSON class

It's not much, but I tried employing some of the things I learned yet never really got to use, since that kind of code isn't really needed where I work (for the most part). I tried making it as much C+...
10
votes
4answers
2k views

BigInteger formatting for endless tower defense game

I am working on an endless tower defense game in Unity. To keep track of money, damage, hitpoints and stuff like that I will be using BigInteger, which can ...
5
votes
2answers
357 views

itoa base function in C

This is a function that converts an integer value to a null-terminated string using the specified base and stores the result in a char array that I must allocate (...
1
vote
1answer
195 views

Custom Exception.ToString() formatter

I find the default Exception.ToString() formattig very difficult to read especially if there are inner exceptions involved. I guess everyone knows how it looks: <...
4
votes
1answer
76 views

Binary-octal-hexadecimal conversion table

I solved this exercise of displaying a table of numbers from 1 to 256 in binary, octal and hexadecimal. I made this program to convert from decimal to binary and took that binary number to convert to ...
7
votes
2answers
123 views

Formatting seconds as hours:minutes:seconds

This is basically my school homework and I want to know what to improve, and what not to do. The homework basically is this: You will get a input in seconds, which is supposed to be shown as H:MM:SS ...
5
votes
1answer
97 views

Java method to make a string representation of a matrix

I have coded this static method for converting a double matrix into a nifty String. It considers the width of the matrix to be ...
1
vote
0answers
26 views

Formatting a CHANGES text file as HTML

I have a function which is used to convert text (a CHANGES file) into HTML for reading. The function is essentially line-based: if the line is of this type, do this thing; if some other type, do that ...
3
votes
1answer
70 views

Extendable format provider

I needed a better string formatting options like ToUpper and ToLower but I also wanted to be able to use the default formattings ...
1
vote
1answer
73 views

Exercism: clean and format a phone number in Clojure

Problem statement Phone Number Write a program that cleans up user-entered phone numbers so that they can be sent SMS messages. The rules are as follows: If the phone number is ...
3
votes
2answers
78 views

Exercise 1-22 from K and R: line folding

I'm currently learning C with K&R, i'm right now in the exercise 1-22, but it's a little... hard to understand (at least for me). It says: Write a program to "fold" long input lines into two ...
1
vote
2answers
34 views
4
votes
2answers
63 views

Function that strips trailing '0's from a float

I'm writing an embedded application in C, and at one point I need to convert a float into an ASCII representation of that float, so I can send the ASCII over a serial port. The protocol the serial ...
1
vote
0answers
26 views

Simple login script

This is a simple login script using Bcrypt. Is there anything wrong with this code? It works and my page loads O.K, but could this be optimized for better speeds? ...
5
votes
1answer
68 views

K&R 1-20 Solution

I'm currently reading the infamous K&R C book and trying to solve Exercise 1-20. My solution looks kind of too simple, but it works. I've searched the web for different solutions, but they all are ...
2
votes
1answer
54 views

Displaying a String array in tabular format

I have an array of strings called theArray. All strings in theArray are of length 20. I wish to display this array in tabular ...