string

Convert LPWSTR to GUID

I'm working with the new Windows 7 audio APIs, and I've hit a wall. Basically, I need to take an IAudioSessionControl2* and get an ISimpleAudioVolume* out of it. Now, it looks like I can call on IAudioSessionManager->GetSimpleAudioVolume() using the value of IAudioSessionControl2->GetSessionInstanceIdentifier(...). Note that this isn'...

Need some help with python string / slicing operations

This is a very newbie question and i will probably get downvoted for it, but i quite honestly couldn't find the answer after at least an hour googling. I learned how to slice strings based on "exact locations" where you have to know exactly where the word ends. But i did not find any article that explained how do it on "non static" strin...

php string versus boolean speed test

I'm looking at trying to optimise a particular function in a php app and foolishly assumed that a boolean lookup in a 'if' statement would be quicker than a string compare. But to check it I put together a short test (see below). To my surprise, the string lookup was quicker. Is there anything wrong with my test (I'm wired on too much c...

Malloc, string pointers, and Valgrind

My program is like this (main.c): #include <stdlib.h> #include <stdio.h> void main(){ char *first="hello "; char *second="world!"; char *seq=(char *)malloc((strlen(first)+1)*sizeof(char)); strcat(strcpy(seq,first),second); printf("%s\n",seq); free(seq); } and I debug with the tool valgrind, it said that($:valgrind --tool=m...

How to leak a string in Delphi

I was talking to a co-worker the other day about how you can leak a string in Delphi if you really mess things up. By default strings are reference counted and automatically allocated, so they typically just work without any thought - no need for manual allocation, size calculations, or memory management. But I remember reading once ...

Convert ListBox.ObjectCollection to String array in VB.NET

I'm programming an application in VB.NET in which I need to take the Items from a ListBox, which are an ListBox.ObjectCollection and convert into a String array to be passed as a parameter to a Sub procedure. How should I do it? ...

Newlines in string not writing out to file

I'm trying to write a program that manipulates unicode strings read in from a file. I thought of two approaches - one where I read the whole file containing newlines in, perform a couple regex substitutions, and write it back out to another file; the other where I read in the file line by line and match individual lines and substitute o...

How do I Convert a String into an Integer in JavaScript?

How do I convert a string into an integer in JavaScript? Is it possible to do this automatically, or do I have to write a subroutine to do it manually? ...

Storing Composite Product Numbers

I am designing a laboratory database. Several products, samples, etc are identified by a composite number with multiple parts which indicate different values such as: origin, date, type, id today, etc. Examples of composite numbers might include a driver's license number (X44-555-3434), lot number (XBR-A26-500-2). How should composite...

C#: How can I safely convert a byte array into a string and back?

I don't really care about encoding and stuff, as long as I get back the exact same byte array. So to sum up: How do I convert a byte array into a string, and then that string back into the same byte array I started with? ...

Unicode versions in .NET

The documentation of CharUnicodeInfo.GetUnicodeCategory says: Note that CharUnicodeInfo.GetUnicodeCategory does not always return the same UnicodeCategory value as the Char.GetUnicodeCategory method when passed a particular character as a parameter. The CharUnicodeInfo.GetUnicodeCategory method is designed to reflect the curren...

Multiple Line String Literal in Actionscript 3

How do you specify a multiple line string literal in Actionscript 3? Multiline String Literal in C# ...

SQL Server convert string to datetime

This is not asking how to convert an arbitrary string to datetime in MSSQL such as this question. I can control the string format but I want to know what the MSSQL syntax is for updating a datetime field using a date string. ...

Get first non-empty string from a list in python

In Python I have a list of strings, some of which may be the empty string. What's the best way to get the first non-empty string? ...

Looking for a good hash table implementation in C

I am primarily interested in string keys. Can someone point me towards a library? -A ...

Is there a way to get non-locking stream insertion/extraction on basic_iostream in Windows?

I'm a C++ developer who has primarily programmed on Solaris and Linux until recently, when I was forced to create an application targeted to Windows. I've been using a communication design based on C++ I/O stream backed by TCP socket. The design is based on a single thread reading continuously from the stream (most of the time blocked i...

What's a quick one-liner to remove empty lines from a python string?

I have some code in a python string that contains extraneous empty lines. I would like to remove all empty lines from the string. What's the most pythonic way to do this? Note: I'm not looking for a general code re-formatter, just a quick one or two-liner. Thanks! ...

Pattern Matching with Lua's string module

I'm trying to use string.find in Lua to parse the contents of a user-entered string. There are up to three different parameters I am trying to find (if the user enters them), but sometimes only one. The input string in its longer form looks like: local userInput = "x|y|z" where x, y, and z can be any character or nothing (empty str...

How to get the first element in a string?

Hello, I'm trying to figure out a way to check a string's first element if it's either a number or not. if not(myString[0] in [0..9]) then //Do something The problem is that I get an error "Element 0 inaccessible - use 'Length' or 'SetLength" Another way came to my head from my C-like exprieince - convert the first element of the st...

Why are strings notoriously expensive

What is it about the way strings are implemented that makes them so expensive to manipulate? Is it impossible to make a "cheap" string implementation? or am I completely wrong in my understanding? Thanks ...