string

In PHP... best way to turn string representation of a folder structure into nested array

Hi everyone, I looked through the related questions for a similar question but I wasn't seeing quite what I need, pardon if this has already been answered already. In my database I have a list of records that I want represented to the user as files inside of a folder structure. So for each record I have a VARCHAR column called "FolderS...

delphi remove . and .. from path

Hello everyone. How can I remove the . and .. from a path in Delphi (not using .NET). I need a function, so I can pass it something like 'c:\program files..\program files...', and I want the function to return to me 'c:\'. Can Delphi do that on its own? Or do I need to do it myself? ...

How to convert hex string to integer in Python ?

How to convert x = "0x000000001" # hex number string to y = "1" ...

django + south + python: strange behavior when using a text string received as a parameter in a function

Hello, this is my first question. I'm trying to execute a SQL query in django (south migration): from django.db import connection # ... class Migration(SchemaMigration): # ... def transform_id_to_pk(self, table): try: db.delete_primary_key(table) except: pass finally: ...

Python string formatting too slow

I use the following code to log a map, it is fast when it only contains zeroes, but as soon as there is actual data in the map it becomes unbearably slow... Is there any way to do this faster? log_file = open('testfile', 'w') for i, x in ((i, start + i * interval) for i in range(length)): log_file.write('%-5d %8.3f %13g %13g %13g %1...

php mysql query strings array

i am building a string that i check in mysql db. eg: formFields[] is an array - input1 is: string1 array_push(strings, formFields) 1st string and mysql query looks like this: "select * from my table where id in (strings)" formFields[] is an array - input2 is: string1, string2 array_push(strings, formFields) 2nd string and mysql query l...

How would I create an object that uses String type behaviour for creation?

I'd like to be able to create an object that is created like a String object, and when created verifies that the String value is an appropriate option. I.E. SpecificString can be "Bob" or "Jim". SpecificString BadName = "Sam" //Throws exception SpecificString GoodName = "Bob" //Does not throw exception. The most important functionali...

Modify strings in Rails?

Hey everyone, So I'm new to Rails (teaching myself as a senior project in high school), and I'm trying to figure out how to modify these strings. Let's say someone writes the following string in a form: "you know you are a geek when" How can I automatically change it to this: "You know you are a geek when..."? I need Rails to check t...

Exchanging strings (PChar) between a Freepascal compiled DLL and a Delphi compiled EXE

After a lot of experimentations, I found a way to exchange PChar from a FreePascal compiled DLL with a Delphi compiled EXE. I'm in charge of both the DLL and EXE source code but one MUST BE in FreePascal and the other one in Delphi. My solution involves the following methods in the DLL: function GetAString(): PChar; var aString: string;...

Difference between various string comparisons in Java

Is there a difference between these ? if(myString.equals("")){ } if(myString.equals(null)){ } if(myString == ""){ } I have a string, I don't know is it empty or has some emtpy spaces I just wan't to stop it to be written in database if it is invalid(if empty or with some blank spaces). ...

Scoping a StringBuilder inside a for loop

When would you ever want to scope a String Builder inside a for loop? Sample Code: .... for (int i=0; i<cnt; i++) { .... { StringBuilder sb = new StringBuilder(); sb.append(","); .... } } .... ...

String to array or Array to string tips on formats, etc

hi, first of all thanks for taking your time! I'm a junior Dev, working with PHP + mysql. My issue: I'm saving data from a form to my database. From this form, there's only need to save the contacts: Name, phone number, address. But, it would be nice to have a small reference to the user answers. Let's say for each question we've go...

C++ How to copy text in string (from i.e. 8 letter to 12 letter)

Hello This is not homework, I need this for my program :) I ask this question, because I searched for this in Google about 1 hour, and I don't find anything ready to run. I know that is trivial question, but if you will help me, you will make my day :) Question: How to copy text in string (from for example 8 letter to 12 letter)...

convert file path to string

I am developing a c# web application with VS 2008 where I am trying to capture the physical path of the selected file. Using IE, I am finally able to retrieve this now in text variable. But I want to capture this information in string. How do I do this? Currently I am using: lb3.Text = Page.Request.PhysicalPath; And it gives me: Tex...

Crystal Reports Formula Workshop boolean condition to string

Hello, I'm currently trying to create a report using Crystal Reports that comes with Visual Studio 2008. I would like to include a field of type boolean on my report that shows a string rather than true or false. The string should contain either contain a € or a % sign. How would I go about doing this in the Formula Workshop? I've tr...

What does `@` mean at the start of a string in C#?

Consider the following line: readonly private string TARGET_BTN_IMG_URL = @"\\ad1-sunglim\Test\"; In this line, why does @ need to be attached? ...

What is the safest way to pass strings around in C?

I have a program in C using Solaris with VERY ancient compatibility it seems. Many examples, even here on SO, don't work, as well as lots of code I've written on Mac OS X. So when using very strict C, what is the safest way to pass strings? I'm currently using char pointers all over the place, due to what I thought was simplicity. So...

How do you print a limited number of characters?

Sorry to put a post up about something so simple, but I don't see what I'm doing wrong here. char data[1024]; DWORD numRead; ReadFile(handle, data, 1024, &numRead, NULL); if (numRead > 0) printf(data, "%.5s"); My intention with the above is to read data from a file, and then only print out 5 characters. However, it prints out al...

Java's equivalence to Python's "Got value: %s" % variable?

Java's equivalence to Python's "Got value: %s" % variable? ...

Why do two array values look the same, but don't evaluate as equal?

When I compare two array values I see two strings that look the same. php doesn't agree. $array1 = array('address'=>'32 Winthrop Street','state'=>'NY'); $array2 = array('address'=>'32 Winthrop Street'); $results = array_diff_assoc($array1, $array2); var_dump($results) //echos ['address'] => string(18) "32 Winthrop Street" ['state']=...