string

speed string search in PHP

Hi! I have a 1.2GB file that contains a one line string. What I need is to search the entire file to find the position of an another string (currently I have a list of strings to search). The way what I'm doing it now is opening the big file and move a pointer throught 4Kb blocks, then moving the pointer X positions back in the file and...

Javascript Hex String to Image

Hello everyone. I'll cut right to the chase. Right now I am developing a web based application. It has a PHP REST based architecture that serves up XML documents. On many of these documents attributes are hex encoded picture strings. On the client side jQuery AJAX fetches an XML document with a picture in it. I need to display said pic...

Trouble with wstringstream

I have a wstringstream: wstringstream sstream; AlterSstream(sstream); wstringstream bar_stream; bar_stream << sstream; bar_stream << "foo"; MessageBoxW( NULL, bar_stream.str().c_str(), L"subject", MB_OK ); This outputs a long string that looks nothing like what I put in it in AlterSstream(): 00000000002CEC58foo AlterSstr...

Can't return a String value and append it...why?

I am writing an app and am having problems returning a simple string value, and I'm not sure why. The function I am using (within a file called APIManager.m) is: - (NSString*) returnVenueUrl { NSString *venueUrl = [devEnvironment stringByAppendingString:@"venue/id/"]; return venueUrl; } I can return this properly by doing this in an...

How to use Unicode in C++?

Assuming a very simple program that: ask a name. store the name in a variable. display the variable content on the screen. It's so simple that is the first thing that one learns. But my problem is that I don't know how to do the same thing if I enter the name using japanese characters. So, if you know how to do this in C++, please ...

Split a long JSON string into lines in Ruby

First, the background: I'm writing a Ruby app that uses SendGrid to send mass emails. SendGrid uses a custom email header (in JSON format) to set recipients, values to substitute, etc. SendGrid's documentation recommends splitting up the header so that the lines are shorter than 1,000 bytes. My question, then, is this: given a long JS...

Convert String To Integer And Vice-Versa

I'm building a calculator application, and I have a Form, with a TextBox called txtVisor, that has the property NumbersOnly = true. I want to get the content of it(that I already know: txtVisor.Text) and convert it into a Integer, to do multiply it by 12, then convert the result into a String to set the txtVisor.Text as the result of the...

C++: use a #define in printf?

I was wanting to use a constant of some kind for the application ID (so I can use it in printf). I had this: #define _APPID_ "Hello World!" And then the simple printf, calling it into %s (string). It put this out: simple.cpp:32: error: cannot convert ‘_IO_FILE*’ to ‘const char*’ for argument ‘1’ to ‘int printf(const char*, ...)’ Wh...

How to manipulate sql connection string in C#

Hi i'm trying to manipulate the sql connection string so instead of running the original copy of our database it runs from the copy one folder up in our C# project. ...

How to get the first n words from text stored in my DB in PHP?

Hi I need to know how to get the first n words from text stored in my DB in PHP? for example if there is some text in my DB like this one : "word1 word2 word3 word4 text one test four five" How I can get the first 4 or five words from this text? Thnks in Advance. ...

Beautify Integer values for comparing as strings

Hi. For some reason I need to enter my integer values to database as string, then I want to run a query on them and compare those integers as strings. Is there any way to beautify integer numbers (between 1 and 1 US billion as an example) so I can compare them as strings? Thanks in advance. ...

ruby write newline character to file but do not interpret as a true newline

I am trying to write a ruby string to a file in such a way that any newline characters embedded in the string remain embedded. This is being written out to a file which will then be processed by another tool. An example is below. I want this: 1 [label="this is a\ntest"] \n (second \n is a true newline) I have tried this: string = '1 [l...

casting BSTR as char* in a dll; different results depnding on VB/C# caller.

I have a dll function that takes BSTR parameters. These are casted as char* before being used for other things. When the dll is called from VB code this works fine. However, when it is called from C# code, only the first character is pointed to. Both of these are excel addIns for Pre-2007 and 2007+ versions of Office, which call into a...

Count the number of times a string appears within a string...

I simply have a string that looks something like this: "7,true,NA,false:67,false,NA,false:5,false,NA,false:5,false,NA,false" All I want to do is to count how many times the string "true" appears in that string. I'm feeling like the answer is something like String.CountAllTheTimesThisStringAppearsInThatString() but for some reason I jus...

Silverlight 4.0 : How to acces to the strings of the ApplicationStrings file through the ResourceWrapper in a business application?

Hi everyone, I want to acces to the strings of the ApplicationStrings file through the ResourceWrapper like this : String loginlabel = ( (ResourceWrapper) App.Current.Resources["ResourceWrapper"] ).ApplicationStrings.LoginLabel; in order to get the good string according to the current culture (language) but it doesn't work at all. A...

Why does RIGHT(@foostr, 0) return NULL when @foostr is varchar(max)?

In SQL Server 2005 If I want to find the right-most one character of a varchar(max) variable, no problem: declare @foostr varchar(max) set @foostr = 'abcd' select right (@foostr, 1) ---- d If I want to find the right-most zero characters of a string literal, no problem: select right ('abcd', 0) ------------------ It returns an e...

How can I set an intent's class from a string value?

I am trying to set the class for an intent to the address listed in a string value, so that I can launch a given activity. The string is composed dynamically during runtime. Is there anyway to make something like the code below run: String target=com.test.activity1.class; Intent intent=new intent(); intent.setClass(this, target); Th...

Aribitrary System.DateTime to four character military time string

Hello, How would I convert an arbitrary System.DateTime to a four character military time string. Example 1: 7am would be "0700" Example 2: 2pm would be "1400" Thanks! ...

Determine precision and scale of particular number in Python

I have a variable in Python containing a floating point number (e.g. num = 24654.123), and I'd like to determine the number's precision and scale values (in the Oracle sense), so 123.45678 should give me (8,5), 12.76 should give me (4,2), etc. I was first thinking about using the string representation (via str or repr), but those fail f...

Trim function in C, to trim in place (without returning the string)

I can't figure out what to do to make this work. Here's my code: char* testStr = " trim this "; char** pTestStr = &testStr; trim(pTestStr); int trim(char** pStr) { char* str = *pStr; while(isspace(*str)) { (*pStr)++; str++; } if(*str == 0) { return 0; } char *end = str + strlen(str) - 1; while(end > s...