string

What's the internal format of a .NET String?

I'm making some pretty string-manipulation-intensive code in C#.NET and got curious about some Joel Spolsky articles I remembered reading a while back: http://www.joelonsoftware.com/articles/fog0000000319.html http://www.joelonsoftware.com/articles/Unicode.html So, how does .NET do it? Two bytes per char? There ARE some Unicode chars^H...

How can I check if a word is contained in another string using PHP?

Pseudo Code text = "I go to school"; word = "to" if ( word.exist(text) ) { return true ; else { return false ; } I am looking for a PHP function which returns true if the word exists in the text. ...

Trimming a white space

In a string that includes quotes, I always get an extra whitespace before the end quote. For instance "this is a test " (string includes quotes) Note the whitespace after test but before the end quote. How could I get rid of this space? I tried rtrim but it just applies for chars at the end of the string, obviously this case is n...

How can I convert String to Int?

I have TextBoxD1.Text and I want to convert it to 'int' to store it in a database. How can I do this? ...

How does one convert a string to lowercase in ruby

I know this is simple, but how do you take a string and convert it to lower case, or upper case in ruby. ...

Best way to randomize a list of strings in Python

I receive as input a list of strings and need to return a list with these same strings but in randomized order. I must allow for duplicates - same string may appear once or more in the input and must appear the same number of times in the output. I see several "brute force" ways of doing that (using loops, god forbid), one of which I'm ...

Python behavior of string in loop

In trying to capitalize a string at separators I encountered behavior I do not understand. Can someone please explain why the string s in reverted during the loop? Thanks. s = 'these-three_words' seperators = ('-','_') for sep in seperators: s = sep.join([i.capitalize() for i in s.split(sep)]) print s print s stdo...

How to transform an HTMLCollection object to a String with XML?

What is the best way to get the full String representation of an HTMLCollection object in javascript/jquery? The output String should have an XML syntax. ...

C# Parse string by parameters Domain="LESSING",Name="Admin"

I have string like \LESSING\root\cimv2:Win32_UserAccount.Domain="LESSING",Name="Admin" How to convert it to LESSING\Admin using Framework? ...

Should I use a string table to make database more efficient?

Let's say you have a database with a single table like... --------------------------------------------- | Name | FavoriteFood | --------------------------------------------- | Alice | Pizza | | Mark | Sushi | | Jack | Pizza | ----...

Delphi: Is it necessary to convert string to WideString?

I found a Windows API function that performs "natural comparison" of strings. It is defined as follows: int StrCmpLogicalW( LPCWSTR psz1, LPCWSTR psz2 ); To use it in delphi, I declared it this way: interface function StrCmpLogicalW(psz1, psz2: PWideChar): integer; stdcall; implementation function StrCmpLogicalW; e...

how to eval() a segment of a string

I have a string that has HTML & PHP in it, when I pull the string from the database, it is echo'd to screen, but the PHP code doesn't display. The string looks like this: $string = 'Hello <?php echo 'World';?>'; echo $string; Output Hello Source Code Hello <?php echo 'World';?> When I look in the source code, I can s...

Determine a string's encoding in C#

Hi, Is there any way to determine a string's encoding in C#? Say, I have a filename string, but I don't know if it is encoded in Unicode UTF-16 or the system-default encoding, how do I find out? Thanks, kreb ...

Optimize F# string concatenation

I'm building a MySql query that batch inserts 4096 records at once. The actual insert is quite fast but the bottleneck is generating the query. Any hints on optimizing this? The string generation is currently taking about 18 times longer than the query. let builder = StringBuilder(524288) Printf.b...

Modifying a C string: access violation

Possible Duplicates: Why does simple C code receive segmentation fault? Modifying C string constants? Why does this code generate an access violation? int main() { char* myString = "5"; *myString = 'e'; // Crash return 0; } ...

How to get number of chars in string in Transact SQL, the "other way"

Hi, we faced very strange issue (really strange for such mature product): how to get number of characters in unicode string using Transact-SQL statements. The key problem of this issue that the len() TSQL function returns number of chars, excluding trailing blanks. the other variant is to use datalength (which return number of bytes) and...

How can I join a list of strings in specman?

I have a list that I want to print: foo: list of string; I want to create a string bar that is the concatenation of the elements of foo. In Perl I would do: $bar = join " ", @foo; The only way I can think of to do this in specman is: var bar: string = ""; for each in foo { bar = appendf("%s %s", bar, it); }; This seems like...

Capitalize first letter of string in javascript

I want to capitalize the first character of a string, and not change the case of any of the other letters. For example: this is a test -> This is a test the Eiffel Tower -> The Eiffel Tower /index.html -> /index.html ...

Comparing strings in C - strcmp

I'm having trouble comparing strings in C (with which I am fairly new to). I have socket on this server application waiting to accept data from a client. In this particular portion of my program I want to be able to execute a MySQL query based on the data received from the client. I want to be able to know when the received data has the ...

Global const string& smells bad to me, is it truly safe?

I'm reviewing a collegue's code, and I see he has several constants defined in the global scope as: const string& SomeConstant = "This is some constant text"; Personally, this smells bad to me because the reference is referring to what I'm assuming is an "anonymous" object constructed from the given char array. Syntactically, it's le...