string

Python convert formatted string to list.

I have a string "[u'foo']" (Yes, it includes the square brackets and the u''). I have to convert that to a list which looks like [u'foo']. list("[u'foo']") won't work. Any suggestions? ...

How to split a string and find the occurence of one string in another?

I need to figure out how to do some C# code in php, and im not sure exactly how. so first off i need the Split function, im going to have a string like "identifier 82asdjka271akshjd18ajjd" and i need to split the identifier word from the rest. so in C#, i used string.Split(new char{' '}); or something like that (working off the to...

is there any better way then this for chracter replacement in string?

Hi there, I am working on my url to make it pretty. and here is the logic i came up with. now in the url i want to achieve something like this. http://domain.com/category/date/post-title for that i first populated the value from the database, i.e date and the post title like this for date: $date = date("d", $row['timestamp']); $...

What's the origin of asking interviewees to manually parse a string as an int?

I'm wondering, what's the origin of asking interviewees to manually parse a string as an int? (without relying on any casting/type-conversion that may be built into the language). Is this a standard question, suggested from a book or list or something? Has anybody else here on SO gotten asked this particular question during an interv...

Add an empty string vs toString - why is it bad?

According to the tool PMD, the following is a bad practice: String s = "" + 123; // bad String t = Integer.toString(456); // ok This is an inefficient way to convert any type to a `String`. Why is it a bad thing to do? ...

VBA problem with String concatenation

I want to create a query like this : SQL = SQL + "Libelle = \"" + Me.Libelle + "\" AND " because if I have a problem with my data if I write like this : SQL = SQL + "Libelle = '" + Me.Libelle + "' AND " but there is a problem with the \" I'm used to use it in Java (I'm not a VBA developper :s) How to resolve it ? thnx ...

Cannot create a program which will invert string

I am using Linux. I am trying to write a program in c that will print a string backward. Here is my code: #include <stdio.h> #include <string.h> #include <stdlib.h> int main (){ char string[100]; printf ("Enter string:\n"); gets (string); int length = strlen (string)-1; for (length = length; length>=0; length--){ ...

c++ sizeof( ... )

#include <cstdlib> #include <iostream> int main(int argc, char *argv[]) { cout << "size of String " << sizeof(string ); system("PAUSE"); return EXIT_SUCCESS; } Output: size of String = 4 Does that mean that, since sizeof(char) = 1 Byte (0 to 255), string can only hold 4 chara...

Problem with string sharing over AppDelegate-Class

I'm sharing my string over the AppDelegate-Class: SpeakersAppDelegate *mainDelegate = (SpeakersAppDelegate *)[[UIApplication sharedApplication] delegate]; [mainDelegate setShareText:xmlString]; And get the string back from the AppDelegate-Class: SpeakersAppDelegate *mainDelegate = (SpeakersAppDelegate *)[[UIApplication sharedApplic...

How to get string width on Android?

I would like to get height too if possible. ...

JavaScript is item a string

While looking at adding a trim function to the String prototype, I came across something that seems odd to me with JavaScript strings. if (typeof console === 'undefined') { var console = { }; console.log = function(msg) { alert(msg) } } function isString(str) { return ((str && typeof str === 'string') || ...

What programming tangle is more evil than C++ strings?

I came from Java/C# and am amazed at the sheer ugliness of strings in C++, particularly the variety of C++ types invented to make strings more pleasant that all still seem to be in use somewhere (std::string std::wstring CString null terminated strings, null terminated strings of tchars, ....) and whose interoperability and encodings onl...

Difference between a double in c# and objective-c when converting to string

I am in the process of migrating the awesome c# geocode framework http://code.google.com/p/geocoordconversion/ to objective-c however I've noticed a subtle difference. There is a line in the code which does the following: int retVal = Math.Abs(allAfterDecimal).ToString().Trim('0').Length - 1; Now I have written matching test scrip...

Automatic Code Generation for Strings.xml from Eclipse

I find it a waste of time that every time I need to enter a string that I have to go edit the strings.xml file manually. What I'd like to be able to do ideally is have Eclipse pop up a dialog box that lets me specify the name of the resource and the value for it. Then Eclipse would generate the code in strings.xml and paste the correct...

Why is my Dictionary adding extra escape characters to a string?

App.config: <?xml version="1.0" encoding="utf-8" ?> <configuration> <appSettings> <add key="1" value="An error occured.\r\nPlease try again later." /> </appSettings> </configuration> Code: Dictionary<string, string> keyValuePairs = new Dictionary<string, string>(); string key = "1"; keyValuePairs.Add(key, ConfigurationManage...

Include various Javascripts without getting "unterminated string literal" error?

I get the "unterminated string literal" error with this code. This code used to work by using escaped quotes. Not possible now because because Google Adsense is including several script files. <script type="text/javascript"> <!-- var t=0; var myArray = []; myArray[0]= 'condition1'; myArray[1]= 'condition2'; myArray[2]= 'condition3';...

In Scala 2.8, how to access a substring by its length and starting index?

I've got date and time in separate fields, in yyyyMMdd and HHmmss formats respectively. To parse them I think to construct a yyyy-MM-ddTHH:mm:ss string and feed this to joda-time constructor. So I am looking to get 1-st 4 digits, then 2 digits starting from the index 5, etc. How to achieve this? List.fromString(String) (which I found her...

c++ - printf on strings prints gibberish

Hi, Sorry about the simple question - I'm a newby (obviously): I'm trying to print a string the following way: int main(){ string s("bla"); printf("%s \n", s); ....... }; but all I get is this random gibberish. Can you please explain why? Thanks, Li ...

Hotstrings / global string replacement while typing in vb.net

Hi, I'm trying to add a feature in a winforms vb.net application i'm writing that would listen to global keyboard input for specefic user entered strings and replace them with another string (all done while the user is typing). In other words, i'm trying to achieve something similar to the autohotkey command: ::tyvm::Thank you very muc...

Why hex in string is not converted to hex when passed through command line argument?

What I understand that hexadecimal numbers can be placed into string using \x. For example 0x41 0x42 can be placed in string as "\x41\x42". char * ptr = "\x41\x42" ; printf( "%s\n" , ptr ) // AB \x is discarded and 41 is considered as a hex by the compiler. But if I pass it to my program through command line arguments, it does not wo...