string

Is it safe to pass Delphi const string params across memory manager boundaries?

Subj. I'd like to use strings instead of PChar because that spares me much casting, but if I just do procedure SomeExternalProc(s: string); external SOMEDLL_DLL; and then implement it in some other project with non-shared memory manager: library SeparateDll; procedure SomeExternalProc(s: string); begin //a bla bla bla //code here...

std::string vs string literal for functions

I was wondering, I normally use std::string for my code, but when you are passing a string in a parameter for a simply comparison, is it better to just use a literal? Consider this function: bool Message::hasTag(string tag) { for(Uint tagIndex = 0; tagIndex < m_tags.size();tagIndex++) { if(m_tags[tagIndex] == tag) ...

[php] [spin] Finding string and replacing with same case string

Hello, I need help while trying to spin articles. I want to find text and replace synonymous text while keeping the case the same. For example, I have a dictionary like: hello|hi|howdy|howd'y I need to find all hello and replace with any one of hi, howdy, or howd'y. Assume I have a sentence: Hello, guys! Shouldn't you say hel...

Convert Money to Text in PHP

I need to convert say $89.50 to Eighty-Nine Dollars and Fifty Cents using PHP. Is there a function I'm missing somewhere? ...

What's the easiest way to convert Int32's bytes to String?

Dim intChunkId As Integer = &H4D546864 Dim strCunnkId As String = "MThd" Dim easiestWay = GetString(intChunkId) ...

What is the fastest substring search algorithm?

OK, so I don't sound like an idiot I'm going to state the problem/requirements more explicitly: Needle (pattern) and haystack (text to search) are both C-style null-terminated strings. No length information is provided; if needed, it must be computed. Function should return a pointer to the first match, or NULL if no match is found. Fa...

Ruby String: how to insert tag every 5 characters

like this: s = 'HelloWorld-Hello guys' I want to inert tag every 5 characters the result I want like this: Hello<wbr>World<wbr>-Hell<wbr>o guys thanks! ...

Getting a meaning of the string

I have the following string "\u3048\u3075\u3057\u3093". I got the string from a web page as part of returned data in JSONP. What is that? It looks like UTF8, but then should it look like "U+3048U+3075U+3057U+3093"? What's the meaning of the backslashes (\)? How can I convert it to a human-readable form? I'm looking to a solution with...

Treat a string as binary in Ruby

I have a string coming from a database, for example 0b0101000. I'd like to cast it to a binary value, in order to apply byte operations on it, like 0b01011000 & (1<<0 | 1<<4) ...

Dynamically evaluating string conditions in C#

I have a collection of strings. I need to find out from this collection strings which satisfies some condition e.g. that string contains A and B or C. These criteria are specified by the user so they are dynamic. In Linq it should be something like, List<String> items = new List<string> { "sdsdsd", "sdsd", "abc"}; var query = from item...

Deplhi to .Net format string conversion

I am looking for a library or snippet to convert Date/Time format strings from Delphi to .Net. This is for Delphi version 2007. For example, Delphi 2007 specifies "m" as month, whereas .Net uses "M". However, in Delphi, if the "m" follows an "h", then it represents a minute value. Are any available, or do I have to roll my own? ...

What is the best way to String.Join a non-string array?

What is a shorthand way to String.Join a non-string array as in the second example? string[] names = { "Joe", "Roger", "John" }; Console.WriteLine("the names are {0}", String.Join(", ", names)); //ok decimal[] prices = { 39.99M, 29.99m, 29.99m, 19.99m, 49.99m }; Console.WriteLine("the prices are {0}", String.Join(", ", prices)); //bad ...

Undefined behaviour (?) in C with char arrays

when i try char bla[32] = "foobar"; int i; putchar(bla[i]); with strlen(bla) < i < 32, bla[i] is always \0. but isn't this in fact undefined behaviour, and should be avoided? ...

Convert and format datetime to String in C#

I have birth dates stored as datetime in SQL Server 2008 like so: 2010-04-25 00:00:00.000 What is the best way, using C#, to convert and format this into a string with a YYYYMMDD format? In the end, all I need is a string like: 20100425 Any help is greatly appreciated! ...

Minor (unimportant) defect in the standard?

This question has no practical issues associated with it, it is more a matter of curiosity and wanting to know if I am taking things too literally ;). So I have been trying to work towards understanding as much of the c++ standard as possible. Today in my delving into the standard I noticed this (ISO/IEC 14882:2003 21.3.4): const_refe...

Python: how to print range a-z?

1. Print a-n: a b c d e f g h i j k l m n 2. Every second in a-n: a c e g i k m 3. Append a-n to index of urls{hello.com/, hej.com/, ..., hallo.com/}: hello.com/a hej.com/b ... hallo.com/n ...

comparing variables for validate addMethod

Ive been struggling with this all day, been close a couple times but nothing seems to work exactly. I have a text input <input type="text" name="USA_sub" id="USA_sub" /> and after that an input <input type="text" name="FirstName" id="FirstName" /> I need to make sure (create a validation rule) that states "#FirstName" 's value must be ...

jQuery / JavaScript - string replace

Hi Assuming we have a comment textarea where the user can enter this code: [quote="comment-1"] How can I replace that code before the form submits with the actual html content from <div id="comment-1"> ? ...

Objective-C: Formatting text in a string object within a plist

Hello - I am a new objective-c/iPhone developer and am wondering if there is any way to apply formatting to text within a string in a plist? I have a plist that is an array of dictionaries. Each dictionary contains a few string objects, some of which I would like to contain lists and paragraphs of information. I am calling these string...

Does the immutable principle still apply when manipulating a char in a string?

If I manipulate a specific char off of a string, would it still be considered as a string manipulation internally by CLR, resulting in temporary string creation? For example : string myString = "String"; myString[0] = 's'; How about creating a char array[] eqvivalent of the string being edited and perform all position specific manipu...