string

Convert File to HEX String Python

How would I convert a file to a HEX string using Python? I have searched all over Google for this, but can't seem to find anything useful. ...

How do you check whether every word in one string is found in another string?

Let's say I have a book title and I search for it in a database. The database produces matches, some of which are full matches and some of which are partial matches. A full match is when every word in the search result is represented by a word in the search terms. (i.e. there does not have to be a complete overlap on both sides) I am o...

Access Shared Preferences from Different Activity (Android)

When you establish a shared preference such as below... public static final String PREFS_HI = "MyPrefsFile"; Can you access it from other activities just like you would normally do? SharedPreferences settings = getSharedPreferences(PREFS_HI, 0); Or is there something unique that you must do to access the preferences? ...

C++ program crashes

I've this assignment to implement strcmp function. Sometimes it runs okay but other times it crashes. Please help me. #include <iostream> using namespace std; int mystrcmp(const char *s1, const char *s2); int main() { cout<<mystrcmp("A","A")<<endl; cout<<mystrcmp("B","A")<<endl; cout<<mystrcmp("A","B")<<endl; cout...

C# generic string parse to any object

I am storing object values in strings e.g., string[] values = new string[] { "213.4", "10", "hello", "MyValue"}; is there any way to generically initialize the appropriate object types? e.g., something like double foo1 = AwesomeFunction(values[0]); int foo2 = AwesomeFunction(values[1]); string foo3 = AwesomeFunction(values[2]); MyEnu...

Write code list collection to string in c#

HI all I have problem when trying to convert list collection string to one line string. But for each item i must edit with specific format. Example List<string> items = new List<string>(); string result = string.Empty; items.Add("First"); items.Add("Second"); items.Add("Last"); result = string.Join(",", items.ToArray()); Console.Writ...

how much bytes will take???

Hello experts, can anyone tell me below string how much bytes will take? string abc = "a"; Thanks in advance:) ...

If Java Strings are immutable and StringBuilder is mutable why they wasting same ammount of memory in my code?

I ran those code and I got some questions, this kinda got wierd. Using String: while(true) { String s = String.valueOf(System.currentTimeMillis()); System.out.println(s); Thread.sleep(10); } Using StringBuilder: StringBuilder s = null; while(true) { s = new StringBuilder(); s.append(System.current...

Removing whitespace

Hi Guys, I am writing html content to a BML file, how can I remove new lines/whitespace so it is all in one long string? does preg_replace("\n","") work? ...

PHP RegEx Capture with Single Quotes

Hi all, I'm trying to capture from the following string: var MyCode = "jdgsrtjd"; var ProductId = 'PX49EZ482H'; var TempPath = 'Media/Pos/'; What I'd like to get is the variable length value between the single quoted ProductId value PX49EX482H I had this, and I think it is close, but the single quotes are tripping me up. I'm not s...

PHP - Get part of string by searching for characters, instead of counting them?

With the substr() function i must enter where i want to cut the string by numbers, is there any way of cutting a string by passing words or characters? Something like this: <?php $string = "Hey there world!"; magic_substr($string, "there ", "!"); // returns "world" ?> Is there a function like that? If so, i've missed something ...

Which is the most clojuresque way to compare characters and string? (single char string)

Hi to everyone, I was wondering about which is the best (clojuresque) way to compare a character and a string in Clojure. Obviously something like that returns false: (= (first "clojure") "c") because first returns a java.lang.Character and "c" is a single character string. Does exists a construct to compare directly char and string w...

Postgres/PHP PDO::PDOStatement->bindParam() to character(1) field

I have code similar to the following: $data['someField'] = (isset($_POST['someField'])) ? 'Y' : 'N'; $stmt = $db->prepare("INSERT INTO public.someTable (someField) VALUES (':someField');"); $stmt->bindParam(':someField', ($data['someField']), PDO::PARAM_STR, 1); $db->beginTransaction(); $stmt->execute(); $db->commit(); The field is a ...

Need to convert double or decimal to string

Hi I need to convert double to string with two decimal digits separated with 'dot' My concern is that dot must be always used as separator. ...

Byte array to utf8 string

How do I get my byte array to a string that handles the Swedish letters å ä ö? I do this at the moment: NSString *hexString = [NSString stringWithFormat:@"%c", resData[i]]; (resData contains ascii characters) But when I use the hexString in my output label I get jibberish for all non English chars. How can I make a selected byte to an ...

Substring indexes off in simple map reading program

Alright, so I'm trying to create a simple RPG game, and my map reading code seems to be off. This is the map reading line: Integer.parseInt(map.data.substring(Map.MAP_START + ((playerPOS - map.width)/2) - 1, Map.MAP_START + ((((playerPOS - map.width)/2) - 1) + map.dataLen))); Now the only tiles in the map are 01 and 00, so when I see ...

MySql : Break string by delimiters (^A)

I have a string that is of the: type 'field1^Afield2^Afield3^A' I need to break this string and get one of the fields. All the string functions I see in MySql that help you break by delimiter expect a string as the delimiter , example: SUBSTRING_INDEX("Hello. Break this. for me", ".", 1) would give = "Hello" How do i break mu string...

strsep segmentation faults on different string pointer/array types

Platform: Linux, OSX Compiler: GCC I've got a simple program which is currently confounding me - I know that I'm messing with a couple different kinds of arrays/pointers to produce this problem - its intentional - I'm trying to understand it. The code as listed will compile and run as expected, but changing data4 in the call to strsep(...

When is it beneficial to flyweight Strings in Java?

I understand the basic idea of java's String interning, but I'm trying to figure out which situations it happens in, and which I would need to do my own flyweighting. Somewhat related: Java Strings: “String s = new String(”silly“);” The best alternative for String flyweight implementation in Java never quite got answered Together t...

string manipulating in C?

I want to print an array of characters, these characters are underscores first. Then the user can write characters on these underscores.I used gotoxy() but it doesn't work properly. That is what i wrote: int main(void) { char arr[20]; int i; char ch; clrscr(); for(i=0;i<=20;i++) { textattr(0x07); ...