string

How to use sets of string in Pascal?

I am writing a little game in which the user is asked for their race and class. There are five possible races of string[5] and four possible classes of string[9]. How do I program pascal to 1. define the five races and four classes as constants, 2. check the user input to see whether the input is within the possible races and classes -...

Parsing Integer to String C

How does one parse an integer to string(char* || char[]) in C? Is there an equivalent String parseInt(int) method from Java in C? ...

is there a string method to capitalize acronyms in python?

This is good: import string string.capwords("proper name") 'Proper Name' This is not so good: string.capwords("I.R.S") 'I.r.s' Is there no string method to do capwords so that it accomodates acronyms? ...

Java library for free-text diff

I need to match up two almost-the-same long freetext strings; i.e., to find index-to-index correspondences wherever possible. Because this is freetext, the comparison should not be line-based as in code diffing. Any suggestions for Java libraries? A simple example (In real life , of course, there would not be extra whitespace to lin...

String syntax question

What I am trying to achieve is to merge three strings. Two are provided as strings; firstname and lastname, while the third is a simple comma/space separator. Given the following lines of code: //Working code var sep = ", "; var fullName = myNewBO[0].LastName + sep + myNewBO[0].FirstName; //Erronous code var fullName = myNewBO[0].LastN...

Length of string variables & char columns

I tend to make the length of character strings some power of two (16, 32, 64). Is there any optimaztion benefit in doing this for objects of type string such as a string variable, a collection of strings, or a column in a database of type string? This is in a .net/sql server environment. ...

Modifying C string constants?

I want to write a function that reverses the given string passed into it. But, I can not. If I supply the doReverse function (see code below) with a character array, my code works well. I can't figure out why this does not work. I am able to access str[0] in doReverse, but I can't change any value of the array by using a char pointer. A...

PHP String to Float

I am not familiar with PHP at all and had a quick question. I have 2 variables @pricePerUnit and @invoicedUnits. Here's the code that is setting these to values: $InvoicedUnits = ((string) $InvoiceLineItem->InvoicedUnits); $pricePerUnit = ((string) $InvoiceLineItem->PricePerUnit); If I output this, I get the correct values. Lets say ...

Make a copy of a char*

I have a function that accepts a char* as one of its parameters. I need to manipulate it, but leave the original char* intact. Essentially, I want to create a working copy of this char*. It seems like this should be easy, but I am really struggling. My first (naive) attempt was to create another char* and set it equal to the original...

Cell Format Strings for Reporting Services/Dundas Charts

Reporting services use format strings to auto format cell data. For example "c2" formats a cell to be displayed as currency with a decimal precision of 2. Does anyone know where I'd find a comprehensive list off all the different formats available? ...

How can I test an NSString for being nil?

Can I simply use if(myString == nil) For some reason a string that I know is null, is failing this statement. ...

C++: is string.empty() always equivalent to string == ""?

Can I make an assumption that given std::string str; ... // do something to str Is the following statement is always true? (str.empty() == (str == "")) ...

How to find similar patterns in lists/arrays of strings

I am looking for ways to find matching patterns in lists or arrays of strings, specifically in .NET, but algorithms or logic from other languages would be helpful. Say I have 3 arrays (or in this specific case List(Of String)) Array1 "Do" "Re" "Mi" "Fa" "So" "La" "Ti" Array2 "Mi" "Fa" "Jim" "Bob" "So" Array3 "Jim" "Bob" "So" "La" "...

How do I read text from a serial port?

I am trying to read data off of a Windows serial port through Java. I have the javax.comm libraries and am able to get some data but not correct data. When I read the port into a byte array and convert it to text I get a series of characters but no real text string. I have tried to specify the byte array as being both "UTF-8" and "US-...

Why is my comparing if statement not working?

Why is the following code (in cocoa) not working? NSString *extension = [fileName pathExtension]; NSString *wantedExtension = @"mp3"; if(extension == wantedExtension){ //work } in Xcode this just runs without warnings or errors but doesn't do what I think it SHOULD do. ...

Pros and Cons of different string types in C++

Sorry to start another of those unanswerable questions on SO, but I'm just curious as to the pros and cons of all the different string types in C++. My particular question is between MFC's CStrings and std::string (since I'm doing Windows only software), but this would extend to any of the string formats in C++. What do you all thing i...

Weighted search algorithm to find like contacts

I need to write an algorithm that returns the closest match for a contact based on the name and address entered by the user. Both of these are troubling, since there are so many ways to enter a company name and address, for instance: Company A, 123 Any Street Suite 200, Anytown, AK 99012 Comp. A, 123 Any St., Suite 200, Anytown, AK 9901...

Data structure for storing strings?

I'm looking for a data structure to store strings in. I require a function in the interface that takes a string as its only parameter and returns a reference/iterator/pointer/handle that can be used to retrieve the string for the rest of the lifetime of the data structure. Set membership, entry deletion etc. is not required. I'm more co...

Making a C++ app scriptable

I have several functions in my program that look like this: void foo(int x, int y) Now I want my program to take a string that looks like: foo(3, 5) And execute the corresponding function. What's the most straightforward way to implement this? When I say straightforward, I mean reasonably extensible and elegant, but it shouldn't t...

How can I replace all the HTML-encoded accents in Perl?

I have the following situation: There is a tool that gets an XSLT from a web interface and embeds the XSLT in an XML file (Someone should have been fired). "Unfortunately" I work in a French speaking country and therefore the XSLT has a number of words with accents. When the XSLT is embedded in the XML, the tool converts all the accents...