16
votes
11answers
23k views

Converting between std::wstring and std::string

While researching ways to convert back and forth between std::wstring and std::string, I found this conversation on the MSDN ...
11
votes
7answers
533 views

Class for handling unit conversions

I am creating a class to be the end all defacto class for handling unit conversions. This is particularly difficult in my company's industry where imperial architectural strings are used as units. I ...
11
votes
2answers
9k views

Integer to Alphabet string (“A”, “B”, …“Z”, “AA”, “AB”…)

So this question is prompted by two things. I found some code in our source control doing this sort of things. These SO questions: ...
6
votes
4answers
659 views

Function to convert ISO-8859-1 to UTF-8

I wrote this function last year to convert between the two encodings and just found it. It takes a text buffer and its size, then converts to UTF-8 if there's enough space. What should be changed to ...
6
votes
4answers
202 views

Better way to repeatedly use istringstream in “counting minutes” challenge

I was doing this easy challenge "Counting Minutes I" from Coderbyte.com where you just calculate the number of minutes between two given times. The second time is always after the first, although it ...
6
votes
5answers
156 views

Convert sequence of number into display string

My requirement is to convert a sequence of numbers into a display string as below. Example Input 1,2,3,4,5,7,7,8,8,8,10,15,10,11,12,88,87,86 Output 1-5,7-8,10-12,15,86-88 ...
6
votes
1answer
150 views

Converting any PHP function toString() like in JS

In JavaScript, any function is basically an object on which you can call (function(){}).toString() to get it's underlying code as a string. I'm working on a ...
6
votes
2answers
278 views

Integer to String recursive method

I was experimenting with lists, sets, and finally maps when I spotted a pattern in my code to make it recursive. Now I haven't used recursion much in the past or at work and I was very excited to have ...
6
votes
1answer
158 views

BBCode to HTML converter using functional programming

I was inspired to write a BBCode to HTML converter as I'm currently learning functional programming. I wanted achieve functional cohesion. jsFiddle I'd like feedback on: structuring of the code. ...
5
votes
3answers
288 views

Displaying TimeSpan as largest interval (with units)

The following method is used in a call center application to display an approximation of remaining time. The call center telephone operator would inform the caller that they could perform their ...
5
votes
3answers
1k views

Converting a range of integers from a string to an IEnumerable

Goal Convert the following into an IEnumerable of integers accounting for the x-y ranges: ...
5
votes
1answer
49 views

Bi-directional atoi()

I am implementing atoi() by traversing a string from the beginning as well as from the end. Is there anything I can improve? ...
5
votes
2answers
60 views

Convert string to multiline text

I made this method that takes any string and transforms it into a multiline text l; each line having the max (character) length specified by the rowLength ...
4
votes
1answer
68 views

Convert hex string to byte array

The goal is to convert a hex string to a byte array with the following requirements: \$O(1)\$ additional space apart from input and output. \$O(n)\$ runtime This mostly just prohibits creating a ...
4
votes
3answers
153 views

Number to words problem

This is a very long solution I've been working on to a Number to Words problem. I've identified that there's a lot of repeating logic (e.g. 'if writing > 0', 'writing = integer /',). How would you ...
4
votes
1answer
20 views

Converting the integers to their equivalent string representations

I have the following function which converts an integer (such as 103 to its string representation "one hundred three"): ...
3
votes
1answer
83 views

Converting from std::wstring to std::string in Linux

I was bothered by inability of C++ to mix cout and wcout in the same program - so I've found this question: Converting between ...
3
votes
1answer
61 views

Displaying TimeSpan as largest interval (with units) - Part II

[This is a follow-up question to: Displaying TimeSpan as largest interval (with units). The code listed here has been refactored since the original question was posed. Please note that the scope of ...
3
votes
1answer
36 views

Replacing Perisan and Arabic digits

I'm using this function to replace UTF-8 characters representing numbers in text with 'normal' digits. I'm wondering if this is optimized code since this is using two ...
2
votes
1answer
81 views

Refactor ConvertorToString class

Help me refactor this class that helps to represent an object state as String: ...
2
votes
1answer
162 views

Implement numbering scheme like A,B,C… AA,AB,… AAA…, similar to converting a number to radix26

I want to implement numbering scheme like Microsoft Word uses for numbering. first one gets = A,next is B, next is C, .... then AA, then AB,....and so on. as shown below ...
1
vote
1answer
210 views

Milliseconds to Time string & Time string to Milliseconds

Fast Time conversion I'm trying to write a very fast time-to-string and string-to-time function. I noticed that on low CPU mobile devices this function has, even if minimal, impact on the ...
0
votes
2answers
655 views

Command line tool for extracting, searching, and converting

I just completed my first real application (command line app). It's simple, but I had no prior knowledge of Python. Everything was hit and miss, with many Python books and help from those in this ...
0
votes
1answer
97 views

Null-delimited to printf %b converter

I wrote a D implementation of the nul2pfb utility from here, as the link to the source code was broken and I wanted to try to learn D. I noticed that it was rather slow (could barely keep up with the ...
-1
votes
2answers
2k views