I have a join function that operates on STL strings. I want to be able to apply it to to a container like this:
getFoos(const std::multimap<std::string, std::string>& map) {
return join_values(",", map.equal_range("foo"));
In other words, find all matching keys in the collection and concatenate the values into a single string wit...
Firstly, the platform is iPhone and label.text changes the label displayed. Consider this scenario:
I've an array of integers. And I want to display it on the screen.
Here's my take on it:
-(IBAction) updateText: (id)sender {
int a[2];
a[0]=1;
a[1]=2;
a[2]=3;
for (int i=0; i<=10;i++)
label.text = [NSString stringB...
Hello,
I'm learning C++ and i'm getting some troubles when i'm trying to use a String in a ifstream method, like this:
string filename;
cout << "Enter the name of the file: ";
cin >> filename;
ifstream file ( filename );
Here is the full code:
// obtaining file size
#include <iostream>
#include <fstream>
using namespace std;
int...
I'm looking for an algorithm that can do a one-to-one mapping of a string onto another string.
I want an algorithm that given an alphabet I can perform a symmetric mapping function.
For example:
Let's consider that I have the alphabet "A","B","C","D","E","F". I want something like F("ABC") = "CEA" and F("CEA") = "ABC" for every N letter...
I'm writing a simple rc4 encryption/decryption utility as a first project. I'm stuck on trying to convert the given string into an array of bytes that can then be manipulated by the core algorithm. How do you convert a string into an array of bytes in functional f#?
//From another thread
let private replace find (repl : string) (str : s...
Hi,
Does anyone know why sometimes an @ is used preceding a commandText string?
both seem to work fine.
command.CommandText = @"SELECT id FROM users";
or
command.CommandText = "SELECT id FROM users";
...
I want to make an array of Unicode characters, but I don't know how to convert integers into a Unicode representation. Here's the code I have so far
NSMutableArray *uniArray = [[NSMutableArray alloc] initWithCapacity:0];
int i;
for (i = 32; i < 300; i++) {
NSString *uniString = [NSString stringWithFormat:@"\u%04X", i];
[uniArray addO...
I need to add some non printable chars to a string in java so it can be sent down a tcp pipe. the chars mean something to the protocol I am using (record separator and end of message respectively)
what is the best way to go about doing this?
Ideally I'l like to refer to them as constants so that I can use string concatonation/stringbui...
By default I use string constants in my code when I have a string of text that will be output to the screen via a messagebox, label, etc. My main reason for doing so is that I do not want these strings to change at runtime and this way nobody really touches them.
My question is:
It seems that from a memory point of view, this approach ...
I would like to replace "." by "," in a String/double that I want to write to a file.
Using the following Java code
double myDouble = myObject.getDoubleMethod(); // returns 38.1882352941176
System.out.println(myDouble);
String myDoubleString = "" + myDouble;
System.out.println(myDoubleString);
myDoubleString.replace(".", ",");
System...
In the Java textbook I'm learning from, it says that this uses "lexicographic ordering" to return an integer. I understand how it works, but what is a specific way this is used in programming?
...
How would you find the value of string that is repeated and the data between it using regexes? For example, take this piece of XML:
<tagName>Data between the tag</tagName>
What would be the correct regex to find these values? (Note that tagName could be anything).
I have found a way that works that involves finding all the tagNames ...
Is there anyway to check if an enum exists by comparing it to a given string? I can't seem to find any such function. I could just try to use the valueOf method and catch an exception but Iv been taught that catching runtime exceptions is not good practice. Anybody have any ideas?
...
i want to convert:
HECHT, WILLIAM
to
Hecht, William
in c#.
any elegant ways of doing this?
...
Ok, I'm fairly new to C sockets but I just need to do some simple sendto() and recvfrom() calls to get a string out across a network, using multicast sockets. After looking around and reading several guides (including Beej's), I found the code below which does the job of listening for messages sent over a multicast socket (which is what ...
In some RightToLeft languages (Like Arabic, Persian, Urdu, etc) each letter can have different shapes. There is isolated form, initial form, and middle form (you can just find it on the Character Map of the windows for any unicode font).
Imagine you need the exact characters that user has been entered on a text box, by default, when you...
Hi guys,
I'm just learning c++ coming from a Java background.
Just playing around with simple classes now, but for some reason the following won't compile, when the same syntax compiles fine elsewhere:
class CardDealer {
private:
string suits[4];
string values[13];
bool cardTaken[4][13];
int getRan...
Hello!
This isn't really an issue, however I am curious. When I save a string in lets say an DataRow, it is cast to Object. When I want to use it, I have to cast it ToString. As far as I know there are several ways of doing this, first is
string name = (string)DataRowObject["name"]; //valid since I know it's a string
and another one ...
1.
static final String memFriendly = "Efficiently stored String";
System.out.println(memFriendly);
2.
System.out.println("Efficiently stored String");
Will Java compiler treat both (1 and 2) of these in the same manner?
FYI: By efficiently I am referring to runtime memory utilization as well as code execution time. e.g. can the 1s...
Hi all, using jQuery I have the following code:
var selectedIdsArray = $("#selectId option:selected").map(function(){return this.value;});
var selectedIdsStr = $.map(selectedIdsArray, function(val){ return "" + val + "";});
It successfully retrieves a string of ids eg. selectedIdsStr = "2,45,245,1" from an <select multiple='multiple'>...